public LineWidthState (LineWidthAction action, CCNode target, float endWidth) : base (action, target) { castedTarget = target as LineNode; if (castedTarget == null) { throw new InvalidOperationException ("The argument target must be a LineNode"); } startWidth = castedTarget.Width; deltaWidth = endWidth - startWidth; }
public LineWidthState(LineWidthAction action, CCNode target, float endWidth) : base(action, target) { castedTarget = target as LineNode; if (castedTarget == null) { throw new InvalidOperationException("The argument target must be a LineNode"); } startWidth = castedTarget.Width; deltaWidth = endWidth - startWidth; }
public LineWidthState(LineWidthAction action, CCNode target) : base(action, target) { var asDrawNode = target as LineNode; if (asDrawNode == null) { throw new InvalidOperationException("The argument target must be a LineNode"); } startWidth = asDrawNode.Width; endWidth = action.EndWidth; deltaWidth = endWidth - startWidth; }
public LineWidthState(LineWidthAction action, CCNode target) : base(action, target) { var asDrawNode = target as LineNode; if (asDrawNode == null) { throw new InvalidOperationException ("The argument target must be a LineNode"); } startWidth = asDrawNode.Width; endWidth = action.EndWidth; deltaWidth = endWidth - startWidth; }
void HandleMoveCircle (CCTouch touch) { const float timeToTake = 1.5f; // in seconds CCFiniteTimeAction coreAction = null; // By default all actions will be added directly to the // root node - it has values for Position, Scale, and Rotation. CCNode nodeToAddTo = drawNodeRoot; switch (VariableOptions [currentVariableIndex]) { case "Position": coreAction = new CCMoveTo(timeToTake, touch.Location); break; case "Scale": var distance = CCPoint.Distance (touch.Location, drawNodeRoot.Position); var desiredScale = distance / DefaultCircleRadius; coreAction = new CCScaleTo (timeToTake, desiredScale); break; case "Rotation": float differenceY = touch.Location.Y - drawNodeRoot.PositionY; float differenceX = touch.Location.X - drawNodeRoot.PositionX; float angleInDegrees = -1 * CCMathHelper.ToDegrees ( (float)Math.Atan2 (differenceY, differenceX)); coreAction = new CCRotateTo (timeToTake, angleInDegrees); break; case "LineWidth": coreAction = new LineWidthAction (timeToTake, touch.Location.X / 40f); // The LineWidthAction is a special action designed to work only on // LineNode instances, so we have to set the nodeToAddTo to the lineNode: nodeToAddTo = lineNode; break; } CCAction easing = null; switch (EasingOptions [currentEasingIndex]) { case "CCEaseBack": if (currentInOutIndex == 0) easing = new CCEaseBackOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseBackIn (coreAction); else easing = new CCEaseBackInOut (coreAction); break; case "CCEaseBounce": if (currentInOutIndex == 0) easing = new CCEaseBounceOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseBounceIn (coreAction); else easing = new CCEaseBounceInOut (coreAction); break; case "CCEaseElastic": if (currentInOutIndex == 0) easing = new CCEaseElasticOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseElasticIn (coreAction); else easing = new CCEaseElasticInOut (coreAction); break; case "CCEaseExponential": if (currentInOutIndex == 0) easing = new CCEaseExponentialOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseExponentialIn (coreAction); else easing = new CCEaseExponentialInOut (coreAction); break; case "CCEaseSine": if (currentInOutIndex == 0) easing = new CCEaseSineOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseSineIn (coreAction); else easing = new CCEaseSineInOut (coreAction); break; } nodeToAddTo.AddAction (easing ?? coreAction); }
private void HandleMoveCircle(CCTouch touch) { const float timeToTake = 1.5f; // in seconds CCFiniteTimeAction coreAction = null; CCNode nodeToAddTo = drawNodeRoot; switch (VariableOptions [currentVariableIndex]) { case "Position": coreAction = new CCMoveTo(timeToTake, touch.Location); break; case "Scale": var distance = CCPoint.Distance (touch.Location, drawNodeRoot.Position); var desiredScale = distance / DefaultCircleRadius; coreAction = new CCScaleTo(timeToTake, desiredScale); break; case "Rotation": float differenceY = touch.Location.Y - drawNodeRoot.PositionY; float differenceX = touch.Location.X - drawNodeRoot.PositionX; float angleInDegrees = -1 * CCMathHelper.ToDegrees( (float)System.Math.Atan2(differenceY, differenceX)); coreAction = new CCRotateTo (timeToTake, angleInDegrees); break; case "LineWidth": coreAction = new LineWidthAction (timeToTake, touch.Location.X / 40.0f); nodeToAddTo = lineNode; break; } CCAction easing = null; switch (EasingOptions [currentEasingIndex]) { case "<None>": // no easing, do nothing, it will be handled below break; case "CCEaseBack": if (currentInOutIndex == 0) easing = new CCEaseBackOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseBackIn (coreAction); else easing = new CCEaseBackInOut (coreAction); break; case "CCEaseBounce": if (currentInOutIndex == 0) easing = new CCEaseBounceOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseBounceIn (coreAction); else easing = new CCEaseBounceInOut (coreAction); break; case "CCEaseElastic": if (currentInOutIndex == 0) easing = new CCEaseElasticOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseElasticIn (coreAction); else easing = new CCEaseElasticInOut (coreAction); break; case "CCEaseExponential": if (currentInOutIndex == 0) easing = new CCEaseExponentialOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseExponentialIn (coreAction); else easing = new CCEaseExponentialInOut (coreAction); break; case "CCEaseSine": if (currentInOutIndex == 0) easing = new CCEaseSineOut (coreAction); else if (currentInOutIndex == 1) easing = new CCEaseSineIn (coreAction); else easing = new CCEaseSineInOut (coreAction); break; } if (easing != null) { nodeToAddTo.AddAction (easing); } else { nodeToAddTo.AddAction (coreAction); } }