public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; // the root object just rotates around m_root = new CCSprite(s_pPathR1); AddChild(m_root, 1); m_root.Position = new CCPoint(s.Width / 2, s.Height / 2); // the target object is offset from root, and the streak is moved to follow it m_target = new CCSprite(s_pPathR1); m_root.AddChild(m_target); m_target.Position = new CCPoint(s.Width / 4, 0); // create the streak object and add it to the scene streak = CCMotionStreak.Create(2, 3, 32, CCTypes.CCGreen, s_streak); streak.FastMode = true; AddChild(streak); // schedule an update on each frame so we can syncronize the streak with the target Schedule(onUpdate); var a1 = new CCRotateBy (2, 360); var action1 = new CCRepeatForever (a1); var motion = new CCMoveBy (2, new CCPoint(100, 0)); m_root.RunAction(new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(motion, motion.Reverse()))); m_root.RunAction(action1); var colorAction = new CCRepeatForever ((CCActionInterval) CCSequence.FromActions( new CCTintTo (0.2f, 255, 0, 0), new CCTintTo (0.2f, 0, 255, 0), new CCTintTo (0.2f, 0, 0, 255), new CCTintTo (0.2f, 0, 255, 255), new CCTintTo (0.2f, 255, 255, 0), new CCTintTo (0.2f, 255, 0, 255), new CCTintTo (0.2f, 255, 255, 255) ) ); streak.RunAction(colorAction); }
public TextLayer() { InitWithColor(CCTypes.CreateColor(32, 32, 32, 255)); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCNode node = new CCNode (); CCActionInterval effect = getAction(); node.RunAction(effect); AddChild(node, 0, EffectTestScene.kTagBackground); CCSprite bg = new CCSprite(TestResource.s_back3); node.AddChild(bg, 0); bg.AnchorPoint = new CCPoint(0.5f, 0.5f); bg.Position = new CCPoint(size.Width / 2, size.Height / 2); CCSprite grossini = new CCSprite(TestResource.s_pPathSister2); node.AddChild(grossini, 1); grossini.Position = new CCPoint(x / 3, y / 2); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back)))); //grossini.runAction(effect); CCSprite tamara = new CCSprite(TestResource.s_pPathSister1); node.AddChild(tamara, 1); tamara.Position = new CCPoint(2 * x / 3, y / 2); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32); label.Position = new CCPoint(x / 2, y - 80); AddChild(label); label.Tag = EffectTestScene.kTagLabel; CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(size.Width / 2 - 100, 30); item2.Position = new CCPoint(size.Width / 2, 30); item3.Position = new CCPoint(size.Width / 2 + 100, 30); AddChild(menu, 1); Schedule(checkAnim); }
public SpriteZVertex() { // // This test tests z-order // If you are going to use it is better to use a 3D projection // // WARNING: // The developer is resposible for ordering it's sprites according to it's Z if the sprite has // transparent parts. // m_dir = 1; m_time = 0; CCSize s = CCDirector.SharedDirector.WinSize; float step = s.Width / 12; CCNode node = new CCNode (); // camera uses the center of the image as the pivoting point node.ContentSize = (new CCSize(s.Width, s.Height)); node.AnchorPoint = (new CCPoint(0.5f, 0.5f)); node.Position = (new CCPoint(s.Width / 2, s.Height / 2)); AddChild(node, 0); for (int i = 0; i < 5; i++) { CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2)); sprite.VertexZ = (10 + i * 40); node.AddChild(sprite, 0); } for (int i = 5; i < 11; i++) { CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121)); sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2)); sprite.VertexZ = 10 + (10 - i) * 40; node.AddChild(sprite, 0); } node.RunAction(new CCOrbitCamera(10, 1, 0, 0, 360, 0, 0)); }
public void bugMe(CCNode node) { node.StopAllActions(); //After this stop next action not working, if remove this stop everything is working node.RunAction(new CCScaleTo(2, 2)); }
public void repeatForever(CCNode pSender) { var repeat = new CCRepeatForever (new CCRotateBy (1.0f, 360)); pSender.RunAction(repeat); }
private void SetAnimatedProperty(string pPropName, CCNode node, object pValue, float fTweenDuraion) { if (fTweenDuraion > 0) { // Create a fake keyframe to generate the action from var kf1 = new CCBKeyframe(); kf1.Value = pValue; kf1.Time = fTweenDuraion; kf1.EasingType = kCCBKeyframeEasing.kCCBKeyframeEasingLinear; // Animate CCActionInterval tweenAction = GetAction(null, kf1, pPropName, node); node.RunAction(tweenAction); } else { // Just set the value if (pPropName == "position") { // Get position type var array = (List<CCBValue>) GetBaseValue(node, pPropName); var type = (kCCBPositionType) array[2].GetIntValue(); // Get relative position var value = (List<CCBValue>) pValue; float x = value[0].GetFloatValue(); float y = value[1].GetFloatValue(); node.Position = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, GetContainerSize(node.Parent), pPropName); } else if (pPropName == "scale") { // Get scale type var array = (List<CCBValue>) GetBaseValue(node, pPropName); var type = (kCCBScaleType) array[2].GetIntValue(); // Get relative scale var value = (List<CCBValue>) pValue; float x = value[0].GetFloatValue(); float y = value[1].GetFloatValue(); CCBHelper.SetRelativeScale(node, x, y, type, pPropName); } else { // [node setValue:value forKey:name]; // TODO only handle rotation, opacity, displayFrame, color if (pPropName == "rotation") { float rotate = ((CCBValue) pValue).GetFloatValue(); node.Rotation = rotate; } else if (pPropName == "opacity") { byte opacity = ((CCBValue) pValue).GetByteValue(); ((ICCRGBAProtocol) node).Opacity = opacity; } else if (pPropName == "displayFrame") { ((CCSprite) node).DisplayFrame = (CCSpriteFrame) pValue; } else if (pPropName == "color") { var color = (ccColor3BWapper) pValue; ((CCSprite) node).Color = color.getColor(); } else { CCLog.Log("unsupported property name is {0}", pPropName); Debug.Assert(false, "unsupported property now"); } } } }
private void RunAction(CCNode node, CCBSequenceProperty pSeqProp, float fTweenDuration) { List<CCBKeyframe> keyframes = pSeqProp.Keyframes; int numKeyframes = keyframes.Count; if (numKeyframes > 1) { // Make an animation! var actions = new List<CCFiniteTimeAction>(); CCBKeyframe keyframeFirst = keyframes[0]; float timeFirst = keyframeFirst.Time + fTweenDuration; if (timeFirst > 0) { actions.Add(new CCDelayTime (timeFirst)); } for (int i = 0; i < numKeyframes - 1; ++i) { CCBKeyframe kf0 = keyframes[i]; CCBKeyframe kf1 = keyframes[i + 1]; CCActionInterval action = GetAction(kf0, kf1, pSeqProp.Name, node); if (action != null) { // Apply easing action = GetEaseAction(action, kf0.EasingType, kf0.EasingOpt); actions.Add(action); } } if (actions.Count > 1) { CCFiniteTimeAction seq = CCSequence.FromActions(actions.ToArray()); node.RunAction(seq); } else { node.RunAction(actions[0]); } } }