public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = CCDirector.SharedDirector.WinSize; // sun CCParticleSystem sun = new CCParticleSun(); sun.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); sun.Position = (new CCPoint(s.Width - 32, s.Height - 32)); sun.TotalParticles = 130; sun.Life = (0.6f); AddChild(sun); // timers m_label0 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label1 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label2 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label3 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label4 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); ScheduleUpdate(); Schedule(step1); Schedule(step2, 0); Schedule(step3, 1.0f); Schedule(step4, 2.0f); m_label0.Position = new CCPoint(s.Width * 1 / 6, s.Height / 2); m_label1.Position = new CCPoint(s.Width * 2 / 6, s.Height / 2); m_label2.Position = new CCPoint(s.Width * 3 / 6, s.Height / 2); m_label3.Position = new CCPoint(s.Width * 4 / 6, s.Height / 2); m_label4.Position = new CCPoint(s.Width * 5 / 6, s.Height / 2); AddChild(m_label0); AddChild(m_label1); AddChild(m_label2); AddChild(m_label3); AddChild(m_label4); // Sprite CCSprite sprite = new CCSprite(s_pPathGrossini); sprite.Position = new CCPoint(40, 50); CCJumpBy jump = new CCJumpBy (3, new CCPoint(s.Width - 80, 0), 50, 4); AddChild(sprite); sprite.RunAction(new CCRepeatForever ( (CCActionInterval) (new CCSequence(jump, jump.Reverse()))) ); // pause button CCMenuItem item1 = new CCMenuItemFont("Pause", onPause); CCMenu menu = new CCMenu(item1); menu.Position = new CCPoint(s.Width / 2, s.Height - 50); AddChild(menu); }
public override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCSprite sprite = new CCSprite(s_pPathGrossini); CCSprite spriteSister1 = new CCSprite(s_pPathSister1); CCSprite spriteSister2 = new CCSprite(s_pPathSister2); sprite.Scale = (1.5f); spriteSister1.Scale = (1.5f); spriteSister2.Scale = (1.5f); sprite.Position = (new CCPoint(x / 2, y / 2)); spriteSister1.Position = (new CCPoint(40, y / 2)); spriteSister2.Position = (new CCPoint(x - 40, y / 2)); CCAction rot = new CCRotateBy (16, -3600); AddChild(sprite); AddChild(spriteSister1); AddChild(spriteSister2); sprite.RunAction(rot); CCActionInterval jump1 = new CCJumpBy (4, new CCPoint(-400, 0), 100, 4); CCActionInterval jump2 = (CCActionInterval)jump1.Reverse(); CCActionInterval rot1 = new CCRotateBy (4, 360 * 2); CCActionInterval rot2 = (CCActionInterval)rot1.Reverse(); spriteSister1.RunAction(new CCRepeat (new CCSequence(jump2, jump1), 5)); spriteSister2.RunAction(new CCRepeat (new CCSequence((CCFiniteTimeAction)(jump1.Copy()), (CCFiniteTimeAction)(jump2.Copy())), 5)); spriteSister1.RunAction(new CCRepeat (new CCSequence(rot1, rot2), 5)); spriteSister2.RunAction(new CCRepeat (new CCSequence((CCFiniteTimeAction)(rot2.Copy()), (CCFiniteTimeAction)(rot1.Copy())), 5)); }
public MenuLayer3() { CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 28; CCLabelBMFont label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel item1 = new CCMenuItemLabel(label, this.menuCallback2); CCMenuItemFont item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback); CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); CCMenuItemSprite item3 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); CCSize s = CCDirector.SharedDirector.WinSize; item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2); item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2); item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100); CCJumpBy jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4); item2.RunAction(new CCRepeatForever ( (CCActionInterval)(CCSequence.FromActions(jump, jump.Reverse())) ) ); CCActionInterval spin1 = new CCRotateBy (3, 360); CCActionInterval spin2 = (CCActionInterval)(spin1.Copy()); CCActionInterval spin3 = (CCActionInterval)(spin1.Copy()); item1.RunAction(new CCRepeatForever (spin1)); item2.RunAction(new CCRepeatForever (spin2)); item3.RunAction(new CCRepeatForever (spin3)); AddChild(menu); }
public override void OnEnter() { base.OnEnter(); CCLens3D lens = new CCLens3D(10, new CCGridSize(32, 24), new CCPoint(100, 180), 150); CCJumpBy move = new CCJumpBy (5, new CCPoint(380, 0), 100, 4); var move_back = (CCActionInterval) move.Reverse(); CCSequence seq = new CCSequence(move, move_back); /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'CCLens3D' as its target. While in cocos2d-x, the target of action only supports CCNode or its subclass, so we make an encapsulation for CCLens3D to achieve that. */ CCDirector director = CCDirector.SharedDirector; CCNode target = Lens3DTarget.Create(lens); // Please make sure the target been added to its parent. AddChild(target); director.ActionManager.AddAction(seq, target, false); RunAction(lens); }
public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; // rotate and jump var jump1 = new CCJumpBy (4, new CCPoint(-s.Width + 80, 0), 100, 4); var jump2 = jump1.Reverse(); var rot1 = new CCRotateBy (4, 360 * 2); var rot2 = rot1.Reverse(); var seq3_1 = new CCSequence(jump2, jump1); var seq3_2 = new CCSequence(rot1, rot2); var spawn = new CCSpawn(seq3_1, seq3_2); var action = new CCSpeed (new CCRepeatForever (spawn), 1.0f); action.Tag = EaseTest.kTagAction1; var action2 = (CCAction) (action.Copy()); var action3 = (CCAction) (action.Copy()); action2.Tag = EaseTest.kTagAction1; action3.Tag = EaseTest.kTagAction1; m_grossini.RunAction(action2); m_tamara.RunAction(action3); m_kathia.RunAction(action); Schedule(altertime, 1.0f); }
public override void OnEnter() { base.OnEnter(); centerSprites(3); var actionTo = new CCJumpTo (2, new CCPoint(300, 300), 50, 4); var actionBy = new CCJumpBy (2, new CCPoint(300, 0), 50, 4); var actionUp = new CCJumpBy (2, new CCPoint(0, 0), 80, 4); var actionByBack = actionBy.Reverse(); m_tamara.RunAction(actionTo); m_grossini.RunAction(new CCSequence(actionBy, actionByBack)); m_kathia.RunAction(new CCRepeatForever (actionUp)); }
public override void RunActionsInSprite(CCSprite sprite) { sprite.RunAction( new CCRepeatForever( new CCSequence( new CCMoveBy(0.05f, new CCPoint(10, 2)), new CCMoveBy(0.05f, new CCPoint(-10, -2))))); CCJumpBy jump = new CCJumpBy(2.0f, new CCPoint(400, 0), 100, 5); CCJumpBy jump_back = (CCJumpBy) jump.Reverse(); sprite.RunAction( new CCRepeatForever( new CCSequence(jump, jump_back) )); }
public override void OnEnter() { base.OnEnter(); alignSpritesLeft(1); var jump = new CCJumpBy (2, new CCPoint(300, 0), 50, 4); var action = new CCSequence(jump, jump.Reverse()); m_grossini.RunAction(action); }
/// <summary> /// Creates a sequence of actions that causes a sprite to jump on the screen. /// </summary> /// <param name="repeatForever">A boolean value that determines if the action should be repeated indefinitely.</param> /// <returns></returns> internal static CCFiniteTimeAction JumpAction(bool repeatForever) { // Create an action to jump the active sprite from it's current position CCActionInterval jumpAction = new CCJumpBy(0.3f, new CCPoint(150, 0), 100, 1); // Setup an action sequence to perform the jump action, then reverse it jumpAction = new CCSequence(jumpAction, jumpAction.Reverse()); // Repeat the jump sequence three times, just for fun jumpAction = new CCRepeat(jumpAction, 3); // If necessary, repeat the jump actions above indefinitely if (repeatForever) jumpAction = new CCRepeatForever(jumpAction); return jumpAction; }