/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ /** * Timeline Frame. * base class * @class */ ccs.Frame = ccs.Class.extend({ _frameIndex: null, _tween: null, _timeline: null, _node: null, _tweenType: null, _easingParam: null, _enterWhenPassed: null, ctor: function(){ this._frameIndex = 0; this._tween = true; this._timeline = null; this._node = null; this._enterWhenPassed = false; this._easingParam = []; }, _emitEvent: function(){ if (this._timeline){ this._timeline.getActionTimeline()._emitFrameEvent(this); } }, _cloneProperty: function(frame){ this._frameIndex = frame.getFrameIndex(); this._tween = frame.isTween(); this._tweenType = frame.getTweenType(); this.setEasingParams(frame.getEasingParams()); }, /** * Set the frame index * @param {number} frameIndex */ setFrameIndex: function(frameIndex){ this._frameIndex = frameIndex; }, /** * Get the frame index * @returns {null} */ getFrameIndex: function(){ return this._frameIndex; }, /** * Set timeline * @param timeline */ setTimeline: function(timeline){ this._timeline = timeline; }, /** * Get timeline * @param timeline * @returns {ccs.timeline} */ getTimeline: function(timeline){ return this._timeline; }, /** * Set Node * @param {_ccsg.Node} node */ setNode: function(node){ this._node = node; }, /** * gets the Node * @return node */ getNode: function(){ return this._node; }, /** * set tween * @param tween */ setTween: function(tween){ this._tween = tween; }, /** * Gets the tween * @returns {boolean | null} */ isTween: function(){ return this._tween; }, /** * the execution of the callback * @override * @param {ccs.Frame} nextFrame */ onEnter: function(nextFrame){ // = 0 }, /** * Each frame logic * @override * @param {number} percent */ apply: function(percent){ if(!this._tween) return; if(this._tweenType !== ccs.FrameEaseType.TWEEN_EASING_MAX && this._tweenType !== ccs.FrameEaseType.LINEAR) percent = this.tweenPercent(percent); this._onApply(percent); }, _onApply: function(percent){ }, /** * to copy object with deep copy. * returns a clone of action. * @override * @return {ccs.Frame} */ clone: function(){ // = 0 }, tweenPercent: function(percent){ var func = ccs.Frame.tweenToMap[this._tweenType]; if(func) return func(percent, this._easingParam); else return percent; }, setEasingParams: function(easingParams){ if(easingParams){ this._easingParam.length = 0; for(var i=0; i