public override void onEnter() { base.onEnter(); // rotate and jump CCActionInterval jump1 = CCJumpBy.actionWithDuration(4, new CCPoint(-400, 0), 100, 4); CCActionInterval jump2 = jump1.reverse() as CCActionInterval; CCActionInterval rot1 = CCRotateBy.actionWithDuration(4, 360 * 2); CCActionInterval rot2 = rot1.reverse() as CCActionInterval; CCFiniteTimeAction seq3_1 = CCSequence.actions(jump2, jump1); CCFiniteTimeAction seq3_2 = CCSequence.actions(rot1, rot2); CCFiniteTimeAction spawn = CCSpawn.actions(seq3_1, seq3_2); CCFiniteTimeAction action = CCRepeatForever.actionWithAction((CCActionInterval)spawn); CCRepeatForever action2 = (CCRepeatForever)(action.copy()); CCRepeatForever action3 = (CCRepeatForever)(action.copy()); m_grossini.runAction(CCSpeed.actionWithAction((CCActionInterval)action, 0.5f)); m_tamara.runAction(CCSpeed.actionWithAction((CCActionInterval)action2, 1.5f)); m_kathia.runAction(CCSpeed.actionWithAction((CCActionInterval)action3, 1.0f)); CCParticleSystem emitter = CCParticleFireworks.node(); emitter.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire"); addChild(emitter); }
public override void onEnter() { base.onEnter(); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(350, 0)); CCActionInterval move_back = (CCActionInterval)move.reverse(); CCActionInterval move_ease_in = CCEaseIn.actionWithAction(move.copy() as CCActionInterval, 3); CCActionInterval move_ease_in_back = move_ease_in.reverse() as CCActionInterval; CCActionInterval move_ease_out = CCEaseOut.actionWithAction(move.copy() as CCActionInterval, 3); CCActionInterval move_ease_out_back = move_ease_out.reverse() as CCActionInterval; CCFiniteTimeAction seq1 = CCSequence.actions(move, move_back); CCFiniteTimeAction seq2 = CCSequence.actions(move_ease_in, move_ease_in_back); CCFiniteTimeAction seq3 = CCSequence.actions(move_ease_out, move_ease_out_back); CCAction a2 = m_grossini.runAction(CCRepeatForever.actionWithAction(seq1 as CCActionInterval)); a2.tag = 1; CCAction a1 = m_tamara.runAction(CCRepeatForever.actionWithAction(seq2 as CCActionInterval)); a1.tag = 1; CCAction a = m_kathia.runAction(CCRepeatForever.actionWithAction(seq3 as CCActionInterval)); a.tag = 1; schedule(new SEL_SCHEDULE(testStopAction), 6.0f); }
public override void onEnter() { base.onEnter(); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(350, 0)); CCActionInterval move_ease_inout1 = CCEaseInOut.actionWithAction(move.copy() as CCActionInterval, 2.0f); CCActionInterval move_ease_inout_back1 = move_ease_inout1.reverse() as CCActionInterval; CCActionInterval move_ease_inout2 = CCEaseInOut.actionWithAction(move.copy() as CCActionInterval, 3.0f); CCActionInterval move_ease_inout_back2 = move_ease_inout2.reverse() as CCActionInterval; CCActionInterval move_ease_inout3 = CCEaseInOut.actionWithAction(move.copy() as CCActionInterval, 4.0f); CCActionInterval move_ease_inout_back3 = move_ease_inout3.reverse() as CCActionInterval; CCFiniteTimeAction seq1 = CCSequence.actions(move_ease_inout1, move_ease_inout_back1); CCFiniteTimeAction seq2 = CCSequence.actions(move_ease_inout2, move_ease_inout_back2); CCFiniteTimeAction seq3 = CCSequence.actions(move_ease_inout3, move_ease_inout_back3); m_tamara.runAction(CCRepeatForever.actionWithAction(seq1 as CCActionInterval)); m_kathia.runAction(CCRepeatForever.actionWithAction(seq2 as CCActionInterval)); m_grossini.runAction(CCRepeatForever.actionWithAction(seq3 as CCActionInterval)); }
public override void onEnter() { base.onEnter(); // rotate and jump CCActionInterval jump1 = CCJumpBy.actionWithDuration(4, new CCPoint(-400, 0), 100, 4); CCActionInterval jump2 = (CCActionInterval)jump1.reverse(); CCActionInterval rot1 = CCRotateBy.actionWithDuration(4, 360 * 2); CCActionInterval rot2 = (CCActionInterval)rot1.reverse(); CCFiniteTimeAction seq3_1 = CCSequence.actions(jump2, jump1); CCFiniteTimeAction seq3_2 = CCSequence.actions(rot1, rot2); CCFiniteTimeAction spawn = CCSpawn.actions(seq3_1, seq3_2); CCSpeed action = CCSpeed.actionWithAction(CCRepeatForever.actionWithAction((CCActionInterval)spawn), 1.0f); action.tag = EaseTest.kTagAction1; CCAction action2 = (CCAction)(action.copy()); CCAction action3 = (CCAction)(action.copy()); action2.tag = EaseTest.kTagAction1; action3.tag = EaseTest.kTagAction1; m_grossini.runAction(action2); //m_grossini.runAction(CCRepeat.actionWithAction(CCSequence.actions(jump2, jump1), 5)); m_tamara.runAction(action3); m_kathia.runAction(action); this.schedule(new SEL_SCHEDULE(altertime), 1.0f);//:@selector(altertime:) interval:1.0f]; }
public TMXIsoZorder() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-zorder"); addChild(map, 0, 1); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); map.position = (new CCPoint(-s.width / 2, 0)); m_tamara = CCSprite.spriteWithFile(s_pPathSister1); map.addChild(m_tamara, map.children.Count); int mapWidth = (int)(map.MapSize.width * map.TileSize.width); m_tamara.positionInPixels = new CCPoint(mapWidth / 2, 0); m_tamara.anchorPoint = new CCPoint(0.5f, 0); CCActionInterval move = CCMoveBy.actionWithDuration(10, new CCPoint(300 * 1 / CCDirector.sharedDirector().ContentScaleFactor, 250 * 1 / CCDirector.sharedDirector().ContentScaleFactor)); CCActionInterval back = (CCActionInterval)move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, back); m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); schedule((this.repositionSprite)); }
public NodeToWorld() { // // This code tests that nodeToParent works OK: // - It tests different anchor Points // - It tests different children anchor points CCSprite back = CCSprite.spriteWithFile(TestResource.s_back3); addChild(back, -10); back.anchorPoint = (new CCPoint(0, 0)); CCSize backSize = back.contentSize; CCMenuItem item = CCMenuItemImage.itemFromNormalImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect); CCMenu menu = CCMenu.menuWithItems(item); menu.alignItemsVertically(); menu.position = (new CCPoint(backSize.width / 2, backSize.height / 2)); back.addChild(menu); CCActionInterval rot = CCRotateBy.actionWithDuration(5, 360); CCAction fe = CCRepeatForever.actionWithAction(rot); item.runAction(fe); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(200, 0)); CCActionInterval move_back = (CCActionInterval)move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); CCAction fe2 = CCRepeatForever.actionWithAction((CCActionInterval)seq); back.runAction(fe2); }
public override void onEnter() { base.onEnter(); m_background.parent.removeChild(m_background, true); m_background = null; CCParallaxNode p = CCParallaxNode.node(); addChild(p, 5); CCSprite p1 = CCSprite.spriteWithFile(TestResource.s_back3); CCSprite p2 = CCSprite.spriteWithFile(TestResource.s_back3); p.addChild(p1, 1, new CCPoint(0.5f, 1), new CCPoint(0, 0)); p.addChild(p2, 2, new CCPoint(1.5f, 1), new CCPoint(0, 0)); m_emitter = CCParticleFlower.node(); m_emitter.Texture = CCTextureCache.sharedTextureCache().addImage(TestResource.s_fire); p1.addChild(m_emitter, 10); m_emitter.position = new CCPoint(250, 200); CCParticleSun par = CCParticleSun.node(); p2.addChild(par, 10); par.Texture = CCTextureCache.sharedTextureCache().addImage(TestResource.s_fire); CCActionInterval move = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0)); CCFiniteTimeAction move_back = move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); p.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); }
public LabelAtlasColorTest() { CCLabelAtlas label1 = CCLabelAtlas.labelWithString("123 Test", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' '); addChild(label1, 0, (int)TagSprite.kTagSprite1); label1.position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = CCLabelAtlas.labelWithString("0123456789", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' '); addChild(label2, 0, (int)TagSprite.kTagSprite2); label2.position = new CCPoint(10, 200); label2.Color = ccRED; CCActionInterval fade = CCFadeOut.actionWithDuration(1.0f); CCFiniteTimeAction fade_in = fade.reverse(); CCFiniteTimeAction seq = CCSequence.actions(fade, fade_in); CCAction repeat = CCRepeatForever.actionWithAction((CCActionInterval)seq); label2.runAction(repeat); m_time = 0; schedule(step); //:@selector(step:)]; }
public override void onEnter() { base.onEnter(); float x, y; CCSize size = CCDirector.sharedDirector().getWinSize(); x = size.width; y = size.height; CCSprite bg = CCSprite.spriteWithFile("Images/background3"); addChild(bg, 0, EffectAdvanceScene.kTagBackground); bg.position = new CCPoint(x / 2, y / 2); grossini = CCSprite.spriteWithFile("Images/grossinis_sister2"); bg.addChild(grossini, 1, EffectAdvanceScene.kTagSprite1); grossini.position = new CCPoint(x / 3.0f, 200); CCActionInterval sc = CCScaleBy.actionWithDuration(2, 5); CCFiniteTimeAction sc_back = sc.reverse(); grossini.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc, sc_back)))); tamara = CCSprite.spriteWithFile("Images/grossinis_sister1"); bg.addChild(tamara, 1, EffectAdvanceScene.kTagSprite2); tamara.position = new CCPoint(2 * x / 3.0f, 200); CCActionInterval sc2 = CCScaleBy.actionWithDuration(2, 5); CCFiniteTimeAction sc2_back = sc2.reverse(); tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc2, sc2_back)))); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28); label.position = new CCPoint(x / 2, y - 80); addChild(label); label.tag = EffectAdvanceScene.kTagLabel; string strSubtitle = subtitle(); if (strSubtitle != null) { CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16); addChild(l, 101); l.position = new CCPoint(size.width / 2, size.height - 80); } CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage("Images/b1", "Images/b2", this, backCallback); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage("Images/r1", "Images/r2", this, restartCallback); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage("Images/f1", "Images/f2", this, nextCallback); CCMenu menu = CCMenu.menuWithItems(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); }
public TMXIsoVertexZ() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-vertexz"); addChild(map, 0, 1); CCSize s = map.contentSize; map.position = new CCPoint(-s.width / 2, 0); ////----UXLOG("ContentSize: %f, %f", s.width,s.height); // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any CCSprite and it will work OK. CCTMXLayer layer = map.layerNamed("Trees"); m_tamara = layer.tileAt(new CCPoint(29, 29)); CCActionInterval move = CCMoveBy.actionWithDuration(10, new CCPoint(300 * 1 / CCDirector.sharedDirector().ContentScaleFactor, 250 * 1 / CCDirector.sharedDirector().ContentScaleFactor)); CCActionInterval back = (CCActionInterval)move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, back); m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); schedule(repositionSprite); }
public SceneTestLayer2() { m_timeCounter = 0; CCMenuItemFont item1 = CCMenuItemFont.itemFromString("replaceScene", this, onReplaceScene); CCMenuItemFont item2 = CCMenuItemFont.itemFromString("replaceScene w/transition", this, onReplaceSceneTran); CCMenuItemFont item3 = CCMenuItemFont.itemFromString("Go Back", this, onGoBack); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.alignItemsVertically(); addChild(menu); CCSize s = CCDirector.sharedDirector().getWinSize(); CCSprite sprite = CCSprite.spriteWithFile(s_pPathGrossini); addChild(sprite); sprite.position = new CCPoint(s.width - 40, s.height / 2); CCActionInterval rotate = CCRotateBy.actionWithDuration(2, 360); CCAction repeat = CCRepeatForever.actionWithAction(rotate); sprite.runAction(repeat); schedule(testDealloc); }
public StressTest2() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCLayer sublayer = CCLayer.node(); CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1); sp1.position = (new CCPoint(80, s.height / 2)); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(350, 0)); CCActionInterval move_ease_inout3 = CCEaseInOut.actionWithAction((CCActionInterval)(move.copy()), 2.0f); CCActionInterval move_ease_inout_back3 = (CCActionInterval)move_ease_inout3.reverse(); CCFiniteTimeAction seq3 = CCSequence.actions(move_ease_inout3, move_ease_inout_back3); sp1.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq3)); sublayer.addChild(sp1, 1); CCParticleFire fire = CCParticleFire.node(); fire.Texture = (CCTextureCache.sharedTextureCache().addImage("Images/fire")); fire.position = (new CCPoint(80, s.height / 2 - 50)); CCActionInterval copy_seq3 = (CCActionInterval)(seq3.copy()); fire.runAction(CCRepeatForever.actionWithAction(copy_seq3)); sublayer.addChild(fire, 2); schedule((shouldNotLeak), 6.0f); addChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1); }
public Test5() { CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1); CCSprite sp2 = CCSprite.spriteWithFile(TestResource.s_pPathSister2); sp1.position = (new CCPoint(100, 160)); sp2.position = (new CCPoint(380, 160)); CCRotateBy rot = CCRotateBy.actionWithDuration(2, 360); CCActionInterval rot_back = rot.reverse() as CCActionInterval; CCAction forever = CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(rot, rot_back)) ); CCAction forever2 = (CCAction)(forever.copy()); forever.tag = (101); forever2.tag = (102); addChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1); addChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); sp1.runAction(forever); sp2.runAction(forever2); schedule(new SEL_SCHEDULE(this.addAndRemove), 2.0f); }
private void performanceActions20(CCSprite pSprite) { Random random = new Random(); CCSize size = CCDirector.sharedDirector().getWinSize(); if (random.Next() < 0.2f) { pSprite.position = new CCPoint((random.Next() % (int)size.width), (random.Next() % (int)size.height)); } else { pSprite.position = new CCPoint(-1000, -1000); } float period = 0.5f + (random.Next() % 1000) / 500.0f; CCRotateBy rot = CCRotateBy.actionWithDuration(period, 360.0f * random.Next()); CCActionInterval rot_back = null; CCAction permanentRotation = CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions(rot, rot_back)); pSprite.runAction(permanentRotation); float growDuration = 0.5f + (random.Next() % 1000) / 500.0f; CCActionInterval grow = CCScaleBy.actionWithDuration(growDuration, 0.5f, 0.5f); CCAction permanentScaleLoop = CCRepeatForever.actionWithAction(CCSequence.actionOneTwo(grow, grow.reverse())); pSprite.runAction(permanentScaleLoop); }
public override bool init() { if (base.init()) { CCSize s = CCDirector.sharedDirector().getWinSize(); CCLayerColor background = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 255, 255)); addChild(background); CCLayerColor sprite_a = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 0, 0, 255), 700, 700); sprite_a.anchorPoint = new CCPoint(0.5f, 0.5f); sprite_a.isRelativeAnchorPoint = true; sprite_a.position = new CCPoint(0.0f, s.height / 2); addChild(sprite_a); sprite_a.runAction(CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions( CCMoveTo.actionWithDuration(1.0f, new CCPoint(1024.0f, 384.0f)), CCMoveTo.actionWithDuration(1.0f, new CCPoint(0.0f, 384.0f))))); CCLayerColor sprite_b = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0, 0, 255, 255), 400, 400); sprite_b.anchorPoint = new CCPoint(0.5f, 0.5f); sprite_b.isRelativeAnchorPoint = true; sprite_b.position = new CCPoint(s.width / 2, s.height / 2); addChild(sprite_b); CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(CCLabelTTF.labelWithString("Flip Me", "Helvetica", 24), this, callBack); CCMenu menu = CCMenu.menuWithItems(label); menu.position = new CCPoint(s.width - 200.0f, 50.0f); addChild(menu); return(true); } return(false); }
public override void onEnter() { base.onEnter(); CCActionInterval effect = (CCActionInterval)(CCSequence.actions(CCDelayTime.actionWithDuration(2.0f), CCShaky3D.actionWithRange(16, false, new ccGridSize(5, 5), 5.0f))); // cleanup CCNode bg = getChildByTag(EffectAdvanceScene.kTagBackground); removeChild(bg, true); // background CCLayerColor layer = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 0, 255)); addChild(layer, -10); CCSprite sprite = CCSprite.spriteWithFile("Images/grossini"); sprite.position = new CCPoint(50, 80); layer.addChild(sprite, 10); // foreground CCLayerColor layer2 = CCLayerColor.layerWithColor(new ccColor4B(0, 255, 0, 255)); CCSprite fog = CCSprite.spriteWithFile("Images/Fog"); ccBlendFunc bf = new ccBlendFunc { src = 0x0302, dst = 0x0303 }; fog.BlendFunc = bf; layer2.addChild(fog, 1); addChild(layer2, 1); layer2.runAction(CCRepeatForever.actionWithAction(effect)); }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); // the root object just rotates around m_root = CCSprite.spriteWithFile(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 = CCSprite.spriteWithFile(s_pPathR1); m_root.addChild(m_target); m_target.position = (new CCPoint(100, 0)); // create the streak object and add it to the scene //m_streak = CCMotionStreak.streakWithFade(2, 3, s_streak, 32, 32, new ccColor4B(0,255,0,255) ); addChild(m_streak); // schedule an update on each frame so we can syncronize the streak with the target schedule(onUpdate); CCActionInterval a1 = CCRotateBy.actionWithDuration(2, 360); CCAction action1 = CCRepeatForever.actionWithAction(a1); CCActionInterval motion = CCMoveBy.actionWithDuration(2, new CCPoint(100, 0)); m_root.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(motion, motion.reverse())))); m_root.runAction(action1); }
public SpriteBatchNodeAliased() { CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 10); addChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSize s = CCDirector.sharedDirector().getWinSize(); CCSprite sprite1 = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121)); sprite1.position = (new CCPoint(s.width / 2 - 100, s.height / 2)); batch.addChild(sprite1, 0, (int)kTagSprite.kTagSprite1); CCSprite sprite2 = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121)); sprite2.position = (new CCPoint(s.width / 2 + 100, s.height / 2)); batch.addChild(sprite2, 0, (int)kTagSprite.kTagSprite2); CCActionInterval scale = CCScaleBy.actionWithDuration(2, 5); CCActionInterval scale_back = (CCActionInterval)scale.reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.actions(scale, scale_back)); CCAction repeat = CCRepeatForever.actionWithAction(seq); CCAction repeat2 = (CCAction)(repeat.copy()); sprite1.runAction(repeat); sprite2.runAction(repeat2); }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = CCDirector.sharedDirector().getWinSize(); // sun //CCParticleSystem sun = CCParticleSun.node(); //sun.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire"); //sun.position = (new CCPoint(s.width - 32, s.height - 32)); ////sun.setTotalParticles(130); //sun.Life = (0.6f); //this.addChild(sun); // timers m_label0 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label1 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label2 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label3 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label4 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); base.scheduleUpdate(); schedule(step1); schedule(step2, 0); schedule(step3, 1.0f); schedule(step4, 2.0f); 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 = CCSprite.spriteWithFile(s_pPathGrossini); sprite.position = new CCPoint(40, 50); CCJumpBy jump = CCJumpBy.actionWithDuration(3, new CCPoint(s.width - 80, 0), 50, 4); addChild(sprite); sprite.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(jump, jump.reverse())) ) ); // pause button CCMenuItem item1 = CCMenuItemFont.itemFromString("Pause", this, onPause); CCMenu menu = CCMenu.menuWithItems(item1); menu.position = new CCPoint(s.width / 2, s.height - 50); addChild(menu); }
public ParticleDemo() { initWithColor(ccTypes.ccc4(127, 127, 127, 255)); m_emitter = null; isTouchEnabled = true; CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28); addChild(label, 100, 1000); label.position = new CCPoint(s.width / 2, s.height - 50); CCLabelTTF tapScreen = CCLabelTTF.labelWithString("(Tap the Screen)", "Arial", 20); tapScreen.position = new CCPoint(s.width / 2, s.height - 80); addChild(tapScreen, 100); CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, new SEL_MenuHandler(backCallback)); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, new SEL_MenuHandler(restartCallback)); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, new SEL_MenuHandler(nextCallback)); CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(this, new SEL_MenuHandler(toggleCallback), CCMenuItemFont.itemFromString("Free Movement"), CCMenuItemFont.itemFromString("Relative Movement"), CCMenuItemFont.itemFromString("Grouped Movement")); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3, item4); menu.position = new CCPoint(0, 0); item1.position = new CCPoint(s.width / 2 - 100, 30); item2.position = new CCPoint(s.width / 2, 30); item3.position = new CCPoint(s.width / 2 + 100, 30); item4.position = new CCPoint(0, 100); item4.anchorPoint = new CCPoint(0, 0); addChild(menu, 100); CCLabelAtlas labelAtlas = CCLabelAtlas.labelWithString("0000", "fonts/fnt/images/fps_images", 16, 24, '.'); addChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas); labelAtlas.position = new CCPoint(s.width - 66, 50); // moving background m_background = CCSprite.spriteWithFile(TestResource.s_back3); addChild(m_background, 5); m_background.position = new CCPoint(s.width / 2 - 120, s.height - 240); CCActionInterval move = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0)); CCFiniteTimeAction move_back = move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); m_background.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); schedule(new SEL_SCHEDULE(step)); }
public SpriteColorOpacity() { CCSprite sprite1 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); CCSprite sprite2 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121)); CCSprite sprite3 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121)); CCSprite sprite4 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121)); CCSprite sprite5 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); CCSprite sprite6 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121)); CCSprite sprite7 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121)); CCSprite sprite8 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121)); CCSize s = CCDirector.sharedDirector().getWinSize(); sprite1.position = new CCPoint((s.width / 5) * 1, (s.height / 3) * 1); sprite2.position = new CCPoint((s.width / 5) * 2, (s.height / 3) * 1); sprite3.position = new CCPoint((s.width / 5) * 3, (s.height / 3) * 1); sprite4.position = new CCPoint((s.width / 5) * 4, (s.height / 3) * 1); sprite5.position = new CCPoint((s.width / 5) * 1, (s.height / 3) * 2); sprite6.position = new CCPoint((s.width / 5) * 2, (s.height / 3) * 2); sprite7.position = new CCPoint((s.width / 5) * 3, (s.height / 3) * 2); sprite8.position = new CCPoint((s.width / 5) * 4, (s.height / 3) * 2); CCActionInterval action = CCFadeIn.actionWithDuration(2); CCActionInterval action_back = (CCActionInterval)action.reverse(); CCAction fade = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action, action_back))); CCActionInterval tintred = CCTintBy.actionWithDuration(2, 0, -255, -255); CCActionInterval tintred_back = (CCActionInterval)tintred.reverse(); CCAction red = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintred, tintred_back))); CCActionInterval tintgreen = CCTintBy.actionWithDuration(2, -255, 0, -255); CCActionInterval tintgreen_back = (CCActionInterval)tintgreen.reverse(); CCAction green = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintgreen, tintgreen_back))); CCActionInterval tintblue = CCTintBy.actionWithDuration(2, -255, -255, 0); CCActionInterval tintblue_back = (CCActionInterval)tintblue.reverse(); CCAction blue = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintblue, tintblue_back))); sprite5.runAction(red); sprite6.runAction(green); sprite7.runAction(blue); sprite8.runAction(fade); // late add: test dirtyColor and dirtyPosition addChild(sprite1, 0, (int)kTagSprite.kTagSprite1); addChild(sprite2, 0, (int)kTagSprite.kTagSprite2); addChild(sprite3, 0, (int)kTagSprite.kTagSprite3); addChild(sprite4, 0, (int)kTagSprite.kTagSprite4); addChild(sprite5, 0, (int)kTagSprite.kTagSprite5); addChild(sprite6, 0, (int)kTagSprite.kTagSprite6); addChild(sprite7, 0, (int)kTagSprite.kTagSprite7); addChild(sprite8, 0, (int)kTagSprite.kTagSprite8); schedule(removeAndAddSprite, 2); }
public SpriteHybrid() { CCSize s = CCDirector.sharedDirector().getWinSize(); // parents CCNode parent1 = CCNode.node(); CCSpriteBatchNode parent2 = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini", 50); addChild(parent1, 0, (int)kTags.kTagNode); addChild(parent2, 0, (int)kTags.kTagSpriteBatchNode); // IMPORTANT: // The sprite frames will be cached AND RETAINED, and they won't be released unless you call // CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames); CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini"); // create 250 sprites // only show 80% of them for (int i = 0; i < 250; i++) { int spriteIdx = (int)(rand.NextDouble() * 14); string str = ""; string temp = ""; if (spriteIdx + 1 < 10) { temp = "0" + (spriteIdx + 1); } else { temp = (spriteIdx + 1).ToString(); } str = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str); CCSprite sprite = CCSprite.spriteWithSpriteFrame(frame); parent1.addChild(sprite, i, i); float x = -1000; float y = -1000; if (rand.NextDouble() < 0.2f) { x = (float)(rand.NextDouble() * s.width); y = (float)(rand.NextDouble() * s.height); } sprite.position = (new CCPoint(x, y)); CCActionInterval action = CCRotateBy.actionWithDuration(4, 360); sprite.runAction(CCRepeatForever.actionWithAction(action)); } m_usingSpriteBatchNode = false; schedule(reparentSprite, 2); }
public Atlas4() { m_time = 0; // Upper Label CCLabelBMFont label = CCLabelBMFont.labelWithString("Bitmap Font Atlas", "fonts/fnt/bitmapFontTest"); addChild(label); CCSize s = CCDirector.sharedDirector().getWinSize(); label.position = new CCPoint(s.width / 2, s.height / 2); label.anchorPoint = new CCPoint(0.5f, 0.5f); CCSprite BChar = (CCSprite)label.getChildByTag(0); CCSprite FChar = (CCSprite)label.getChildByTag(7); CCSprite AChar = (CCSprite)label.getChildByTag(12); CCActionInterval rotate = CCRotateBy.actionWithDuration(2, 360); CCAction rot_4ever = CCRepeatForever.actionWithAction(rotate); CCActionInterval scale = CCScaleBy.actionWithDuration(2, 1.5f); CCFiniteTimeAction scale_back = scale.reverse(); CCFiniteTimeAction scale_seq = CCSequence.actions(scale, scale_back); CCAction scale_4ever = CCRepeatForever.actionWithAction((CCActionInterval)scale_seq); CCActionInterval jump = CCJumpBy.actionWithDuration(0.5f, new CCPoint(), 60, 1); CCAction jump_4ever = CCRepeatForever.actionWithAction(jump); CCActionInterval fade_out = CCFadeOut.actionWithDuration(1); CCActionInterval fade_in = CCFadeIn.actionWithDuration(1); CCFiniteTimeAction seq = CCSequence.actions(fade_out, fade_in); CCAction fade_4ever = CCRepeatForever.actionWithAction((CCActionInterval)seq); BChar.runAction(rot_4ever); BChar.runAction(scale_4ever); FChar.runAction(jump_4ever); AChar.runAction(fade_4ever); // Bottom Label CCLabelBMFont label2 = CCLabelBMFont.labelWithString("00.0", "fonts/fnt/bitmapFontTest"); addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.position = new CCPoint(s.width / 2.0f, 80); CCSprite lastChar = (CCSprite)label2.getChildByTag(3); lastChar.runAction((CCAction)(rot_4ever.copy())); //schedule( schedule_selector(Atlas4::step), 0.1f); base.schedule(step, 0.1f); }
public override void onEnter() { base.onEnter(); centerSprites(2); CCActionInterval act1 = CCRotateTo.actionWithDuration(1, 90); CCActionInterval act2 = CCRotateTo.actionWithDuration(1, 0); CCActionInterval seq = (CCActionInterval)(CCSequence.actions(act1, act2)); CCAction rep1 = CCRepeatForever.actionWithAction(seq); CCActionInterval rep2 = CCRepeat.actionWithAction((CCFiniteTimeAction)(seq.copy()), 10); m_tamara.runAction(rep1); m_kathia.runAction(rep2); }
public override void onEnter() { base.onEnter(); centerSprites(3); CCActionInterval actionTo = CCJumpTo.actionWithDuration(2, new CCPoint(300, 300), 50, 4); CCActionInterval actionBy = CCJumpBy.actionWithDuration(2, new CCPoint(300, 0), 50, 4); CCActionInterval actionUp = CCJumpBy.actionWithDuration(2, new CCPoint(0, 0), 80, 4); CCFiniteTimeAction actionByBack = actionBy.reverse(); m_tamara.runAction(actionTo); m_grossini.runAction(CCSequence.actions(actionBy, actionByBack)); m_kathia.runAction(CCRepeatForever.actionWithAction(actionUp)); }
public Atlas3() { m_time = 0; CCLayerColor col = CCLayerColor.layerWithColor(new ccColor4B(128, 128, 128, 255)); addChild(col, -10); CCLabelBMFont label1 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2"); // testing anchors label1.anchorPoint = new CCPoint(0, 0); addChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); CCActionInterval fade = CCFadeOut.actionWithDuration(1.0f); CCFiniteTimeAction fade_in = fade.reverse(); CCFiniteTimeAction seq = CCSequence.actions(fade, fade_in); CCAction repeat = CCRepeatForever.actionWithAction((CCActionInterval)seq); label1.runAction(repeat); // VERY IMPORTANT // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected CCLabelBMFont label2 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2"); // testing anchors label2.anchorPoint = new CCPoint(0.5f, 0.5f); label2.Color = ccRED; addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.runAction((CCAction)(repeat.copy())); CCLabelBMFont label3 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2"); // testing anchors label3.anchorPoint = new CCPoint(1, 1); addChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); CCSize s = CCDirector.sharedDirector().getWinSize(); label1.position = new CCPoint(); label2.position = new CCPoint(s.width / 2, s.height / 2); label3.position = new CCPoint(s.width, s.height); base.schedule(step);//:@selector(step:)]; }
public override void onEnter() { base.onEnter(); centerSprites(2); CCFiniteTimeAction seq = CCSequence.actions( CCRotateTo.actionWithDuration(0.5f, -20), CCRotateTo.actionWithDuration(0.5f, 20)); CCActionInterval rep1 = CCRepeat.actionWithAction(seq, 10); CCAction rep2 = CCRepeatForever.actionWithAction((CCActionInterval)(seq.copy())); m_tamara.runAction(rep1); m_kathia.runAction(rep2); }
public void addNewSprite() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCPoint p = new CCPoint((float)(rand.NextDouble() * s.width), (float)(rand.NextDouble() * s.height)); int idx = (int)(rand.NextDouble() * 1400 / 100); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCNode node = getChildByTag((int)kTags.kTagSpriteBatchNode); CCSprite sprite = CCSprite.spriteWithTexture(m_texture1, new CCRect(x, y, 85, 121)); node.addChild(sprite); sprite.position = (new CCPoint(p.x, p.y)); CCActionInterval action; float random = (float)rand.NextDouble(); if (random < 0.20) { action = CCScaleBy.actionWithDuration(3, 2); } else if (random < 0.40) { action = CCRotateBy.actionWithDuration(3, 360); } else if (random < 0.60) { action = CCBlink.actionWithDuration(1, 3); } else if (random < 0.8) { action = CCTintBy.actionWithDuration(2, 0, -255, -255); } else { action = CCFadeOut.actionWithDuration(2); } CCActionInterval action_back = (CCActionInterval)action.reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.actions(action, action_back)); sprite.runAction(CCRepeatForever.actionWithAction(seq)); }
public override void onEnter() { base.onEnter(); alignSpritesLeft(2); CCActionInterval a1 = CCMoveBy.actionWithDuration(1, new CCPoint(150, 0)); CCActionInterval action1 = CCRepeat.actionWithAction( CCSequence.actions(CCPlace.actionWithPosition(new CCPoint(60, 60)), a1), 3); CCAction action2 = CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions((CCActionInterval)(a1.copy()), a1.reverse())) ); m_kathia.runAction(action1); m_tamara.runAction(action2); }
public override void onEnter() { base.onEnter(); centerSprites(1); CCSize s = CCDirector.sharedDirector().getWinSize(); m_grossini.position = new CCPoint(-200, s.height / 2); CCActionInterval move = CCMoveBy.actionWithDuration(2, new CCPoint(s.width * 3, 0)); CCFiniteTimeAction move_back = move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); CCAction rep = CCRepeatForever.actionWithAction((CCActionInterval)seq); m_grossini.runAction(rep); this.runAction(CCFollow.actionWithTarget(m_grossini, new CCRect(0, 0, s.width * 2 - 100, s.height))); }