Beispiel #1
0
        public override void update(float t)
        {
            float newT = 0;

            if (FloatUtils.EQ(t, 0) || FloatUtils.EQ(t, 1))
            {
                newT = t;
            }
            else
            {
                t = t * 2;
                if (!FloatUtils.EQ(_period, 0))
                {
                    _period = 0.3f * 1.5f;
                }
                float s = _period / 4;

                t = t - 1;
                if (FloatUtils.Small(t, 0))
                {
                    newT = -0.5f * Mathf.Pow(2, 10 * t) * Mathf.Sin((t - s) * (Mathf.PI * 2) / _period);
                }
                else
                {
                    newT = Mathf.Pow(2, -10 * t) * Mathf.Sin((t - s) * (Mathf.PI * 2) / _period) * 0.5f + 1;
                }
            }
            _inner.update(newT);
        }
Beispiel #2
0
        /** initializes the action with a set boundary */
        public void initWithTarget(CCNode fNode, Rect rect)
        {
            base.init();
            _followedNode         = fNode;
            _boundarySet          = true;
            _boundaryFullyCovered = false;

            Vector2 winSize = CCDirector.sharedDirector.winSize;

            _fullScreenSize = winSize;
            _halfScreenSize = _fullScreenSize * .5f;

            _leftBoundary   = -((rect.position.x + rect.size.x) - _fullScreenSize.x);
            _rightBoundary  = -rect.position.x;
            _topBoundary    = -rect.position.y;
            _bottomBoundary = -((rect.position.y + rect.size.y) - _fullScreenSize.y);

            if (FloatUtils.Small(_rightBoundary, _leftBoundary))
            {
                // screen width is larger than world's boundary width
                //set both in the middle of the world
                _rightBoundary = _leftBoundary = (_leftBoundary + _rightBoundary) / 2;
            }
            if (FloatUtils.Small(_topBoundary, _bottomBoundary))
            {
                // screen width is larger than world's boundary width
                //set both in the middle of the world
                _topBoundary = _bottomBoundary = (_topBoundary + _bottomBoundary) / 2;
            }

            if (FloatUtils.EQ(_topBoundary, _bottomBoundary) && FloatUtils.EQ(_leftBoundary, _rightBoundary))
            {
                _boundaryFullyCovered = true;
            }
        }
        public override void update(float t)
        {
            // waits until enough time has passed for the next shake
            if (FloatUtils.EQ(shakeInterval, 0))
            {
            }              // shake every frame!
            else if (FloatUtils.Small(t, nextShake))
            {
                return;                 // haven't reached the next shake point yet
            }
            else
            {
                nextShake += shakeInterval;                 // proceed with shake this time and increment for next shake goal
            }
            // calculate the dampening effect, if being used
            if (dampening)
            {
                float dFactor = (1 - t);
                amplitude.x = dFactor * startAmplitude.x;
                amplitude.y = dFactor * startAmplitude.y;
            }

            Vector2 newp = new Vector2((Random.Range(0, 100) / 100.0f * amplitude.x * 2) - amplitude.x, (Random.Range(0, 100) / 100.0f * amplitude.y * 2) - amplitude.y);

            // simultaneously un-move the last shake and move the next shake
            ((CCNode)_target).position = ((CCNode)_target).position - last + newp;

            // store the current shake value so it can be un-done
            last = newp;
        }
Beispiel #4
0
 public CCDelayTime(float d)
 {
     if (FloatUtils.EQ(d, 0))
     {
         d = FloatUtils.Epsilon;
     }
     initWithDuration(d);
 }
 public static bool EqualToTransform(CGAffineTransform t1, CGAffineTransform t2)
 {
     return(FloatUtils.EQ(t1.a, t2.a) &&
            FloatUtils.EQ(t1.b, t2.b) &&
            FloatUtils.EQ(t1.c, t2.c) &&
            FloatUtils.EQ(t1.d, t2.d) &&
            FloatUtils.EQ(t1.tx, t2.tx) &&
            FloatUtils.EQ(t1.ty, t2.ty));
 }
        public override void update(float t)
        {
            float newT = t;

            // prevents rounding errors
            if (!FloatUtils.EQ(t, 0) && !FloatUtils.EQ(t, 1))
            {
                newT = 1 - bounceTime(1 - t);
            }

            _inner.update(newT);
        }
 public override void update(float t)
 {
     // added to support overriding setScale only
     if (FloatUtils.EQ(_startScaleX, _startScaleY) && FloatUtils.EQ(_endScaleX, _endScaleY))
     {
         (_target as CCNode).scale = _startScaleX + _deltaX * t;
     }
     else
     {
         (_target as CCNode).scaleX = _startScaleX + _deltaX * t;
         (_target as CCNode).scaleY = _startScaleY + _deltaY * t;
     }
 }
Beispiel #8
0
 /** triggers the timer */
 public void update(float dt)
 {
     if (FloatUtils.EQ(_elapsed, -1))
     {
         _elapsed        = 0;
         _nTimesExecuted = 0;
     }
     else
     {
         if (_runForever && !_useDelay)
         {
             //standard timer usage
             _elapsed += dt;
             if (FloatUtils.EB(_elapsed, _interval))
             {
                 trigger();
                 _elapsed = 0;
             }
         }
         else
         {
             //advanced usage
             _elapsed += dt;
             if (_useDelay)
             {
                 if (FloatUtils.EB(_elapsed, _delay))
                 {
                     trigger();
                     _elapsed         = _elapsed - _delay;
                     _nTimesExecuted += 1;
                     _useDelay        = false;
                 }
             }
             else
             {
                 if (FloatUtils.EB(_elapsed, _interval))
                 {
                     trigger();
                     _elapsed         = 0;
                     _nTimesExecuted += 1;
                 }
             }
             if (!_runForever && FloatUtils.Big(_nTimesExecuted, _repeat))
             {
                 cancel();
             }
         }
     }
 }
        /** Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
         * The matrix is in Pixels.
         * @since v0.7.1
         */
        public CGAffineTransform nodeToParentTransform()
        {
            if (_isTransformDirty)
            {
                // Translate values
                float x = _position.x;
                float y = _position.y;

                if (_ignoreAnchorPointForPosition)
                {
                    x += _anchorPointInPixels.x;
                    y += _anchorPointInPixels.y;
                }

                // Rotation values
                // Change rotation code to handle X and Y
                // If we skew with the exact same value for both x and y then we're simply just rotating
                float cx = 1, sx = 0, cy = 1, sy = 0;
                if (!FloatUtils.EQ(_rotation, 0))
                {
                    float radiansX = -ccUtils.CC_DEGREES_TO_RADIANS(_rotation);
                    float radiansY = -ccUtils.CC_DEGREES_TO_RADIANS(_rotation);
                    cx = Mathf.Cos(radiansX);
                    sx = Mathf.Sin(radiansX);
                    cy = Mathf.Cos(radiansY);
                    sy = Mathf.Sin(radiansY);
                }

                // optimization:
                // inline anchor point calculation if skew is not needed
                // Adjusted transform calculation for rotational skew
                if (_anchorPointInPixels != Vector2.zero)
                {
                    x += cy * -_anchorPointInPixels.x * _scaleX + -sx * -_anchorPointInPixels.y * _scaleY;
                    y += sy * -_anchorPointInPixels.x * _scaleX + cx * -_anchorPointInPixels.y * _scaleY;
                }


                // Build Transform Matrix
                // Adjusted transfor m calculation for rotational skew
                _transform = CGAffineTransform.Make(cy * _scaleX, sy * _scaleX,
                                                    -sx * _scaleY, cx * _scaleY,
                                                    x, y);

                _isTransformDirty = false;
            }

            return(_transform);
        }
Beispiel #10
0
        /** initializes the action */
        public virtual void initWithDuration(float d)
        {
            base.init();
            _duration = d;

            // prevent division by 0
            // This comparison could be in step:, but it might decrease the performance
            // by 3% in heavy based action games.
            if (FloatUtils.EQ(_duration, 0))
            {
                _duration = float.Epsilon;
            }
            _elapsed   = 0;
            _firstTick = true;
        }
Beispiel #11
0
        public override void update(float t)
        {
            float newT = 0;

            if (FloatUtils.EQ(t, 0) || FloatUtils.EQ(t, 1))
            {
                newT = t;
            }
            else
            {
                float s = _period / 4;
                newT = Mathf.Pow(2, -10 * t) * Mathf.Sin((t - s) * (Mathf.PI * 2) / _period) + 1;
            }
            _inner.update(newT);
        }
Beispiel #12
0
        public override void update(float t)
        {
            // prevents rouding errors
            if (!FloatUtils.EQ(t, 1) && !FloatUtils.EQ(t, 0))
            {
                t *= 2;
                if (FloatUtils.Small(t, 1))
                {
                    t = 0.5f * Mathf.Pow(2, 10 * (t - 1));
                }
                else
                {
                    t = 0.5f * (-Mathf.Pow(2, -10 * (t - 1)) + 2);
                }
            }

            _inner.update(t);
        }
        public static CGAffineTransform Invert(CGAffineTransform xform)
        {
            CGAffineTransform result;
            float             determinant;

            determinant = xform.a * xform.d - xform.c * xform.b;
            if (FloatUtils.EQ(determinant, 0))
            {
                return(xform);
            }

            result.a  = xform.d / determinant;
            result.b  = -xform.b / determinant;
            result.c  = -xform.c / determinant;
            result.d  = xform.a / determinant;
            result.tx = (-xform.d * xform.tx + xform.c * xform.ty) / determinant;
            result.ty = (xform.b * xform.tx - xform.a * xform.ty) / determinant;

            return(result);
        }
        public override void update(float t)
        {
            float newT;

            // prevents possible rounding errors
            if (FloatUtils.EQ(t, 0) || FloatUtils.EQ(t, 1))
            {
                newT = t;
            }
            else if (FloatUtils.Small(t, 0.5f))
            {
                t    = t * 2;
                newT = (1 - bounceTime(1 - t)) * 0.5f;
            }
            else
            {
                newT = bounceTime(t * 2 - 1) * 0.5f + 0.5f;
            }

            _inner.update(newT);
        }
        // Helper
        protected bool updateTexture()
        {
            if (FloatUtils.EQ(_dimensions.x, 0) || FloatUtils.EQ(_dimensions.y, 0))
            {
                _content.mesh.text = _text;
                Bounds  localBounds = getLocalbounds();
                Vector2 textSize    = ccUtils.UnitsToPixels(localBounds.size);
                this.contentSize = textSize;
            }
            else
            {
                string finalText         = "";
                string originalText      = _text;
                int    preEmptyCharIndex = -1;
                for (int i = 1; i <= originalText.Length; i++)
                {
                    char c = originalText[i - 1];
                    if (char.IsWhiteSpace(c))
                    {
                        preEmptyCharIndex = i - 1;
                    }
                    string tmpStr = originalText.Substring(0, i);
                    if (c == '\n')
                    {
                        finalText   += tmpStr;
                        originalText = originalText.Substring(i);
                        i            = 0;
                    }

                    _content.mesh.text = tmpStr;
                    Bounds  localBounds = getLocalbounds();
                    Vector2 csize       = ccUtils.UnitsToPixels(localBounds.size);
                    if (FloatUtils.Big(csize.x, _dimensions.x))
                    {
                        if (preEmptyCharIndex == -1)
                        {
                            tmpStr = originalText.Substring(0, i);
                        }
                        else
                        {
                            tmpStr            = originalText.Substring(0, preEmptyCharIndex);
                            i                 = preEmptyCharIndex + 1;
                            preEmptyCharIndex = -1;
                        }
                        finalText += tmpStr;
                        if (i < originalText.Length)
                        {
                            finalText   += "\n";
                            originalText = originalText.Substring(i);
                            i            = 0;
                        }
                    }
                    else if (i == originalText.Length)
                    {
                        tmpStr     = originalText.Substring(0, i);
                        finalText += tmpStr;
                        break;
                    }

//					string tmpStr = originalText.Substring(0, i);
//					_content.mesh.text = tmpStr;
//					Vector2 csize = _content.renderer.bounds.size;
//					csize = ccUtils.UnitsToPixels(csize);
//					if(FloatUtils.Small(csize.x , _dimensions.x) || i==1){
//						tmpStr = originalText.Substring(0, i);
//						finalText += tmpStr;
//						if(i<originalText.Length){
//							finalText += "\n";
//							originalText = originalText.Substring(i);
//							i = originalText.Length+1;
//						}else{
//							break;
//						}
//					}
                }
                _content.mesh.text = finalText;
                this.contentSize   = _dimensions;
            }
            _isContentDirty = true;

            return(true);
        }
Beispiel #16
0
 public override void update(float t)
 {
     _inner.update(FloatUtils.EQ(t, 1) ? 1 : (-Mathf.Pow(2, -10 * t / 1) + 1));
 }
		public void OnUpdate(CADisplayLink sender) {
			bool hasTouchesBegan = false;
			bool hasTouchesMoved = false;
			bool hasTouchesEnded = false;
			bool hasTouchesCancelled = false;
			int touchCount = Input.touchCount;
			if (touchCount > 0) {
				int count = Input.touches.Length;
				for (int i=0; i<count; i++) {
					Touch touch = Input.touches [i];
					UITouch uiTouch = new UITouch ();
					uiTouch.fingerId = touch.fingerId;
					uiTouch.phase = touch.phase;
					uiTouch.location = Camera.main.ScreenToWorldPoint (touch.position) * PIXEL_PER_UNIT;
					uiTouch.tapCount = touch.tapCount;
					uiTouch.timestamp = DateTime.Now;
					if (touch.phase == TouchPhase.Began) {
						touchesBegan.Add (uiTouch);
						hasTouchesBegan = true;
					} else if (touch.phase == TouchPhase.Moved) {
						touchesMoved.Add (uiTouch);
						hasTouchesMoved = true;
					} else if (touch.phase == TouchPhase.Ended) {
						touchesEnded.Add (uiTouch);
						hasTouchesEnded = true;
					} else if (touch.phase == TouchPhase.Canceled) {
						touchesCancelled.Add (uiTouch);
						hasTouchesCancelled = true;
					}
				} 
			} else {
				#if UNITY_EDITOR
				#if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_WP8_1
				if(Input.GetMouseButtonDown(0)){
					UITouch uiTouch = new UITouch();
					uiTouch.fingerId = UITouch.SINGLE_TOUCH_ID;
					uiTouch.phase = TouchPhase.Began;
					uiTouch.location = Camera.main.ScreenToWorldPoint(Input.mousePosition) * PIXEL_PER_UNIT;
					uiTouch.tapCount = 1;
					uiTouch.timestamp = DateTime.Now;
					
					touchesBegan.Add (uiTouch);
					hasTouchesBegan = true;
				}else if(Input.GetMouseButtonUp(0)){
					UITouch uiTouch = new UITouch();
					uiTouch.fingerId = UITouch.SINGLE_TOUCH_ID;
					uiTouch.phase = TouchPhase.Ended;
					uiTouch.location = Camera.main.ScreenToWorldPoint(Input.mousePosition) * PIXEL_PER_UNIT;
					uiTouch.tapCount = 1;
					uiTouch.timestamp = DateTime.Now;
					
					touchesEnded.Add (uiTouch);
					hasTouchesEnded = true;
				}else if(Input.GetMouseButton(0)){
					UITouch uiTouch = new UITouch();
					uiTouch.fingerId = UITouch.SINGLE_TOUCH_ID;
					uiTouch.phase = TouchPhase.Moved;
					uiTouch.location = Camera.main.ScreenToWorldPoint(Input.mousePosition) * PIXEL_PER_UNIT;
					uiTouch.tapCount = 1;
					uiTouch.timestamp = DateTime.Now;
					
					touchesMoved.Add (uiTouch);
					hasTouchesMoved = true;
				}
				#endif
				#endif
			}
			if (hasTouchesBegan)
				_rootViewController.view.touchesBegan (touchesBegan);
			if (hasTouchesMoved)
				_rootViewController.view.touchesMoved (touchesMoved);
			if (hasTouchesEnded)
				_rootViewController.view.touchesEnded (touchesEnded);
			if (hasTouchesCancelled)
				_rootViewController.view.touchesCancelled (touchesCancelled);
			touchesBegan.Clear ();
			touchesMoved.Clear ();
			touchesEnded.Clear ();
			touchesCancelled.Clear ();
			
			#if UNITY_STANDALONE || UNITY_WEBGL
			if (Input.GetMouseButtonDown (0)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.mouseDown (nsevent);
			} else if (Input.GetMouseButtonUp (0)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.mouseUp (nsevent);
			} else if (Input.GetMouseButton (0)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.mouseDragged (nsevent);
			} else if (Input.GetMouseButtonDown (1)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.rightMouseDown (nsevent);
			} else if (Input.GetMouseButtonUp (1)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.rightMouseUp (nsevent);
			} else if (Input.GetMouseButton (1)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.rightMouseDragged (nsevent);
			} else if (Input.GetMouseButtonDown (2)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.otherMouseDown (nsevent);
			} else if (Input.GetMouseButtonUp (2)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.otherMouseUp (nsevent);
			} else if (Input.GetMouseButton (2)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.otherMouseDragged (nsevent);
			}else{
				float d = Input.GetAxis("Mouse ScrollWheel");
				if(!FloatUtils.EQ(d, 0)){
					NSEvent wheelEvt = getMouseEvent();
					wheelEvt.mouseWheelDelta = d;
					_rootViewController.view.scrollWheel(wheelEvt);
				}
				float dx = Input.GetAxis("Mouse X");
				float dy = Input.GetAxis("Mouse Y");
				if(!FloatUtils.EQ(dx, 0) || !FloatUtils.EQ(dy, 0)){
					NSEvent nsevent = getMouseEvent ();
					nsevent.mouseDelta = new Vector2(dx, dy) * PIXEL_PER_UNIT;
					_rootViewController.view.mouseMoved(nsevent);
				}
			}
			//Keybaord Events
			keyboardEvent();

			#endif
		}
        public static CCTMXMap Parse(string file, NSDictionary tilesetCaches = null)
        {
            string      text   = LoadText(file);
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(text);
            XmlNodeList nodeList = xmlDoc.DocumentElement.ChildNodes;

            // get mapWidth, mapHeight, tileWidth, tileHeight
            XmlNode mapNode = xmlDoc.DocumentElement;

            float version = float.Parse(mapNode.Attributes["version"].InnerText);

            if (!FloatUtils.EQ(version, 1.0f))
            {
                CCDebug.Warning("cocos2d:CCTMXMap: Found {0} tmx file, but only 1.0 version was tested.", version);
            }

            string dir = file.Replace(Path.GetFileName(file), "");

            CCTMXMap map = new CCTMXMap();

            map.fileName   = file;
            map.cols       = int.Parse(mapNode.Attributes["width"].InnerText);
            map.rows       = int.Parse(mapNode.Attributes["height"].InnerText);
            map.tileWidth  = int.Parse(mapNode.Attributes["tilewidth"].InnerText);
            map.tileHeight = int.Parse(mapNode.Attributes["tileheight"].InnerText);

            Dictionary <int, string> gidToFiles = new Dictionary <int, string> (256);
            Dictionary <int, Dictionary <string, string> > gidToTileProperties = new Dictionary <int, Dictionary <string, string> > (256);
            List <CCTMXLayer> layers = new List <CCTMXLayer> (8);


            var enumerator = nodeList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                XmlNode nodeData = (XmlNode)enumerator.Current;
                if (nodeData.Name == "tileset")
                {
                    ParseTileset(nodeData, gidToFiles, gidToTileProperties, dir, tilesetCaches);
                }
                else if (nodeData.Name == "layer")
                {
                    CCTMXLayer layer = ParseLayer(nodeData, map.cols, map.rows, gidToFiles, gidToTileProperties);
                    layers.Add(layer);
                }
                else if (nodeData.Name == "objectgroup")
                {
                    CCTMXLayer layer = ParseObjectGroup(nodeData, map.cols, map.rows, map.tileWidth, map.tileHeight, gidToFiles, gidToTileProperties);
                    layers.Add(layer);
                }
                else if (nodeData.Name == "properties")
                {
                    if (map.properties == null)
                    {
                        map.properties = new Dictionary <string, string>();
                    }
                    ParseProperties(nodeData, map.properties);
                }
            }
            map.gidToFiles          = gidToFiles;
            map.gidToTileProperties = gidToTileProperties;
            map.layers = layers.ToArray();
            return(map);
        }
Beispiel #19
0
 public override void update(float t)
 {
     _inner.update(FloatUtils.EQ(t, 0) ? 0 : Mathf.Pow(2, 10 * (t / 1 - 1)) /* - 1 * 0.001f */);
 }
        //-------------update------------

        /** 'update' the scheduler.
         * You should NEVER call this method, unless you know what you are doing.
         */
        public void update(float dt)
        {
            if (_paused)
            {
                return;
            }
            updateHashLocked = true;
            if (!FloatUtils.EQ(_timeScale, 1.0f))
            {
                dt *= _timeScale;
            }

            // Iterate all over the Updates selectors
            // updates with priority < 0
            {
                for (utNode <tListEntry> tmp = updatesNeg.head; tmp != null; tmp = tmp.next)
                {
                    utNode <tListEntry> entry = tmp;
                    if (!entry.obj.paused && !entry.obj.markedForDeletion)
                    {
                        entry.obj.impMethod.Invoke(dt);
                    }
                }
            }
            // updates with priority == 0
            {
                for (utNode <tListEntry> tmp = updates0.head; tmp != null; tmp = tmp.next)
                {
                    utNode <tListEntry> entry = tmp;
                    if (!entry.obj.paused && !entry.obj.markedForDeletion)
                    {
                        entry.obj.impMethod.Invoke(dt);
                    }
                }
            }
            // updates with priority > 0
            {
                for (utNode <tListEntry> tmp = updatesPos.head; tmp != null; tmp = tmp.next)
                {
                    utNode <tListEntry> entry = tmp;
                    if (!entry.obj.paused && !entry.obj.markedForDeletion)
                    {
                        entry.obj.impMethod.Invoke(dt);
                    }
                }
            }

//			 Iterate all over the custom selectors (CCTimers)
            if (hashForTimers.Any())
            {
                var enumerator = new Dictionary <int, tHashTimerEntry>(hashForTimers).GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var elt = enumerator.Current.Value;
                    currentTarget         = elt;
                    currentTargetSalvaged = false;
                    if (!currentTarget.paused)
                    {
                        for (elt.timerIndex = 0; elt.timerIndex < elt.timers.Count; elt.timerIndex++)
                        {
                            elt.currentTimer         = elt.timers[elt.timerIndex];
                            elt.currentTimerSalvaged = false;
                            elt.currentTimer.update(dt);
                            elt.currentTimer = null;
                        }
                    }
                    if (currentTargetSalvaged && currentTarget.timers.Count == 0)
                    {
                        removeHashElement(currentTarget);
                    }
                }
            }


            for (utNode <tListEntry> tmp = updatesNeg.head; tmp != null; tmp = tmp.next)
            {
                utNode <tListEntry> entry = tmp;
                if (entry.obj.markedForDeletion)
                {
                    removeUpdatesFromHash(entry);
                }
            }

            for (utNode <tListEntry> tmp = updates0.head; tmp != null; tmp = tmp.next)
            {
                utNode <tListEntry> entry = tmp;
                if (entry.obj.markedForDeletion)
                {
                    removeUpdatesFromHash(entry);
                }
            }


            for (utNode <tListEntry> tmp = updatesPos.head; tmp != null; tmp = tmp.next)
            {
                utNode <tListEntry> entry = tmp;
                if (entry.obj.markedForDeletion)
                {
                    removeUpdatesFromHash(entry);
                }
            }
            updateHashLocked = false;
            currentTarget    = null;
        }
 protected override CCAction reverseImpl()
 {
     return(new CCShake(this.duration, amplitude, dampening, FloatUtils.EQ(shakeInterval, 0) ? 0 : Mathf.RoundToInt(1 / shakeInterval)));
 }
        public override void update(float t)
        {
            int   found = 0;
            float new_t = 0;

            CCAction action0 = _actions [0];
            CCAction action1 = _actions [1];

            if (FloatUtils.Small(t, _split))
            {
                // action[0]
                found = 0;
                if (!FloatUtils.EQ(_split, 0))
                {
                    new_t = t / _split;
                }
                else
                {
                    new_t = 1;
                }
            }
            else
            {
                // action[1]
                found = 1;
                if (FloatUtils.EQ(_split, 1))
                {
                    new_t = 1;
                }
                else
                {
                    new_t = (t - _split) / (1 - _split);
                }
            }

            if (found == 1)
            {
                if (_last == -1)
                {
                    // action[0] was skipped, execute it.
                    action0.startWithTarget(_target);
                    action0.update(1.0f);
                    action0.stop();
                }
                else if (_last == 0)
                {
                    // switching to action 1. stop action 0.
                    action0.update(1.0f);
                    action0.stop();
                }
            }
            else if (found == 0 && _last == 1)
            {
                // Reverse mode ?
                // XXX: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode"
                // since it will require a hack to know if an action is on reverse mode or not.
                // "step" should be overriden, and the "reverseMode" value propagated to inner Sequences.
                action1.update(0);
                action1.stop();
            }

            // Last action found and it is done.
            if (found == _last && _actions[found].isDone())
            {
                return;
            }

            // New action. Start it.
            if (found != _last)
            {
                _actions[found].startWithTarget(_target);
            }

            _actions[found].update(new_t);
            _last = found;
        }