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 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 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); }
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 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); }
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 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 void delay2(float dt) { CCSprite node = (CCSprite)(getChildByTag(2)); CCAction action1 = CCRotateBy.actionWithDuration(1, 360); node.runAction(action1); }
public override void runThisTest() { CCLayer pLayer = RotateWorldMainLayer.node(); addChild(pLayer); runAction(CCRotateBy.actionWithDuration(4, -360)); CCDirector.sharedDirector().replaceScene(this); }
public TMXReadWriteTest() { m_gid = 0; CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test2"); addChild(map, 0, TileMapTestScene.kTagTileMap); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); CCTMXLayer layer = map.layerNamed("Layer 0"); layer.Texture.setAntiAliasTexParameters(); map.scale = 1; CCSprite tile0 = layer.tileAt(new CCPoint(1, 63)); CCSprite tile1 = layer.tileAt(new CCPoint(2, 63)); CCSprite tile2 = layer.tileAt(new CCPoint(3, 62));//ccp(1,62)); CCSprite tile3 = layer.tileAt(new CCPoint(2, 62)); tile0.anchorPoint = new CCPoint(0.5f, 0.5f); tile1.anchorPoint = new CCPoint(0.5f, 0.5f); tile2.anchorPoint = new CCPoint(0.5f, 0.5f); tile3.anchorPoint = new CCPoint(0.5f, 0.5f); CCActionInterval move = CCMoveBy.actionWithDuration(0.5f, new CCPoint(0, 160)); CCActionInterval rotate = CCRotateBy.actionWithDuration(2, 360); CCActionInterval scale = CCScaleBy.actionWithDuration(2, 5); CCActionInterval opacity = CCFadeOut.actionWithDuration(2); CCActionInterval fadein = CCFadeIn.actionWithDuration(2); CCActionInterval scaleback = CCScaleTo.actionWithDuration(1, 1); CCActionInstant finish = CCCallFuncN.actionWithTarget(this, removeSprite); CCFiniteTimeAction seq0 = CCSequence.actions(move, rotate, scale, opacity, fadein, scaleback, finish); CCActionInterval seq1 = (CCActionInterval)(seq0.copy()); CCActionInterval seq2 = (CCActionInterval)(seq0.copy()); CCActionInterval seq3 = (CCActionInterval)(seq0.copy()); tile0.runAction(seq0); tile1.runAction(seq1); tile2.runAction(seq2); tile3.runAction(seq3); m_gid = layer.tileGIDAt(new CCPoint(0, 63)); ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid); schedule(updateCol, 2.0f); schedule(repaintWithGID, 2.0f); schedule(removeTiles, 1.0f); ////----UXLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads()); ////----UXLOG("++++children: %d", layer->getChildren()->count() ); m_gid2 = 0; }
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 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 override void onEnter() { base.onEnter(); alignSpritesLeft(1); CCAction action = CCSpawn.actions( CCJumpBy.actionWithDuration(2, new CCPoint(300, 0), 50, 4), CCRotateBy.actionWithDuration(2, 720)); m_grossini.runAction(action); }
public override void onEnter() { base.onEnter(); alignSpritesLeft(1); CCFiniteTimeAction action = CCSequence.actions( CCMoveBy.actionWithDuration(2, new CCPoint(240, 0)), CCRotateBy.actionWithDuration(2, 540)); m_grossini.runAction(action); }
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 SpriteBatchNodeAnchorPoint() { // small capacity. Testing resizing. // Don't use capacity=1 in your real game. It is expensive to resize the capacity CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 1); addChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSize s = CCDirector.sharedDirector().getWinSize(); CCActionInterval rotate = CCRotateBy.actionWithDuration(10, 360); CCAction action = CCRepeatForever.actionWithAction(rotate); for (int i = 0; i < 3; i++) { CCSprite sprite = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121)); sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2)); CCSprite point = CCSprite.spriteWithFile("Images/r1"); point.scale = 0.25f; point.position = sprite.position; addChild(point, 1); switch (i) { case 0: sprite.anchorPoint = new CCPoint(0, 0); break; case 1: sprite.anchorPoint = (new CCPoint(0.5f, 0.5f)); break; case 2: sprite.anchorPoint = (new CCPoint(1, 1)); break; } point.position = sprite.position; CCAction copy = (CCAction)(action.copy()); sprite.runAction(copy); batch.addChild(sprite, i); } }
public MenuLayer3() { CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 28; CCLabelBMFont label = CCLabelBMFont.labelWithString("Enable AtlasItem", "fonts/fnt/bitmapFontTest3"); CCMenuItemLabel item1 = CCMenuItemLabel.itemWithLabel(label, this, this.menuCallback2); CCMenuItemFont item2 = CCMenuItemFont.itemFromString("--- Go Back ---", this, this.menuCallback); m_item2 = item2; m_item1 = item1; CCSprite spriteNormal = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); CCMenuItemSprite item3 = CCMenuItemSprite.itemFromNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; m_item3 = item3; CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(0, 0); addChild(menu); CCSize s = CCDirector.sharedDirector().getWinSize(); m_item1.position = new CCPoint(s.width / 2 - 150, s.height / 2); m_item2.position = new CCPoint(s.width / 2 - 200, s.height / 2); m_item3.position = new CCPoint(s.width / 2, s.height / 2 - 100); CCJumpBy jump = CCJumpBy.actionWithDuration(3, new CCPoint(400, 0), 50, 4); CCActionInterval spin1 = CCRotateBy.actionWithDuration(3, 360); CCActionInterval spin2 = (CCActionInterval)(spin1.copy()); CCActionInterval spin3 = (CCActionInterval)(spin1.copy()); m_item1.runAction(CCRepeatForever.actionWithAction(spin1)); m_item2.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(jump, jump.reverse())) ) ); m_item2.runAction(CCRepeatForever.actionWithAction(spin2)); // Augments the jump m_item3.runAction(CCRepeatForever.actionWithAction(spin3)); }
public void addNewSpriteWithCoords(CCPoint p) { CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)getChildByTag((int)kTags.kTagSpriteBatchNode); int idx = (int)(rand.NextDouble() * 1400 / 100); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = CCSprite.spriteWithTexture(BatchNode.Texture, new CCRect(x, y, 85, 121)); BatchNode.addChild(sprite); sprite.position = (new CCPoint(p.x, p.y)); CCActionInterval action = null; 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 Sprite6() { // small capacity. Testing resizing // Don't use capacity=1 in your real game. It is expensive to resize the capacity CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 1); addChild(batch, 0, kTagSpriteBatchNode); batch.isRelativeAnchorPoint = false; CCSize s = CCDirector.sharedDirector().getWinSize(); batch.anchorPoint = new CCPoint(0.5f, 0.5f); batch.contentSize = (new CCSize(s.width, s.height)); // SpriteBatchNode actions CCActionInterval rotate = CCRotateBy.actionWithDuration(5, 360); CCAction action = CCRepeatForever.actionWithAction(rotate); // SpriteBatchNode actions CCActionInterval rotate_back = (CCActionInterval)rotate.reverse(); CCActionInterval rotate_seq = (CCActionInterval)(CCSequence.actions(rotate, rotate_back)); CCAction rotate_forever = CCRepeatForever.actionWithAction(rotate_seq); CCActionInterval scale = CCScaleBy.actionWithDuration(5, 1.5f); CCActionInterval scale_back = (CCActionInterval)scale.reverse(); CCActionInterval scale_seq = (CCActionInterval)(CCSequence.actions(scale, scale_back)); CCAction scale_forever = CCRepeatForever.actionWithAction(scale_seq); float step = s.width / 4; for (int i = 0; i < 3; i++) { CCSprite sprite = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121)); sprite.position = (new CCPoint((i + 1) * step, s.height / 2)); sprite.runAction((CCAction)(action.copy())); batch.addChild(sprite, i); } batch.runAction(scale_forever); batch.runAction(rotate_forever); }
public override void onEnter() { base.onEnter(); float x, y; CCSize size = CCDirector.sharedDirector().getWinSize(); x = size.width; y = size.height; CCSprite sprite = CCSprite.spriteWithFile(s_pPathGrossini); CCSprite spriteSister1 = CCSprite.spriteWithFile(s_pPathSister1); CCSprite spriteSister2 = CCSprite.spriteWithFile(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 = CCRotateBy.actionWithDuration(16, -3600); addChild(sprite); addChild(spriteSister1); addChild(spriteSister2); sprite.runAction(rot); 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(); spriteSister1.runAction(CCRepeat.actionWithAction(CCSequence.actions(jump2, jump1), 5)); spriteSister2.runAction(CCRepeat.actionWithAction(CCSequence.actions((CCFiniteTimeAction)(jump1.copy()), (CCFiniteTimeAction)(jump2.copy())), 5)); spriteSister1.runAction(CCRepeat.actionWithAction(CCSequence.actions(rot1, rot2), 5)); spriteSister2.runAction(CCRepeat.actionWithAction(CCSequence.actions((CCFiniteTimeAction)(rot2.copy()), (CCFiniteTimeAction)(rot1.copy())), 5)); }
public override void onEnter() { base.onEnter(); float x, y; CCSize size = CCDirector.sharedDirector().getWinSize(); x = size.width; y = size.height; CCNode blue = CCLayerColor.layerWithColor(new ccColor4B(0, 0, 255, 255)); CCNode red = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 0, 255)); CCNode green = CCLayerColor.layerWithColor(new ccColor4B(0, 255, 0, 255)); CCNode white = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 255, 255)); blue.scale = (0.5f); blue.position = (new CCPoint(-x / 4, -y / 4)); blue.addChild(SpriteLayer.node()); red.scale = (0.5f); red.position = (new CCPoint(x / 4, -y / 4)); green.scale = (0.5f); green.position = (new CCPoint(-x / 4, y / 4)); green.addChild(TestLayer.node()); white.scale = (0.5f); white.position = (new CCPoint(x / 4, y / 4)); addChild(blue, -1); addChild(white); addChild(green); addChild(red); CCAction rot = CCRotateBy.actionWithDuration(8, 720); blue.runAction(rot); red.runAction((CCAction)(rot.copy())); green.runAction((CCAction)(rot.copy())); white.runAction((CCAction)(rot.copy())); }
public override void onEnter() { base.onEnter(); centerSprites(3); CCActionInterval actionTo = CCRotateTo.actionWithDuration(2, 45); CCActionInterval actionTo2 = CCRotateTo.actionWithDuration(2, -45); CCActionInterval actionTo0 = CCRotateTo.actionWithDuration(2, 0); m_tamara.runAction(CCSequence.actions(actionTo, actionTo0)); CCActionInterval actionBy = CCRotateBy.actionWithDuration(2, 360); CCFiniteTimeAction actionByBack = actionBy.reverse(); m_grossini.runAction(CCSequence.actions(actionBy, actionByBack)); // m_kathia->runAction( CCSequence::actions(actionTo2, actionTo0->copy()->autorelease(), NULL)); m_kathia.runAction(CCSequence.actions(actionTo2, actionTo0)); }
public void addNewSpriteWithCoords(CCPoint p) { int idx = (int)(ccMacros.CCRANDOM_0_1() * 1400.0f / 100.0f); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(x, y, 85, 121)); addChild(sprite); sprite.position = p; CCActionInterval action; float random = ccMacros.CCRANDOM_0_1(); 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); } object obj = action.reverse(); CCActionInterval action_back = (CCActionInterval)action.reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.actions(action, action_back)); sprite.runAction(CCRepeatForever.actionWithAction(seq)); }
public SceneTestLayer3() { base.isTouchEnabled = true; CCLabelTTF label = CCLabelTTF.labelWithString("Touch to popScene", "Arial", 28); addChild(label); CCSize s = CCDirector.sharedDirector().getWinSize(); label.position = (new CCPoint(s.width / 2, s.height / 2)); 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(); }
public ConvertToNode() { this.isTouchEnabled = true; CCSize s = CCDirector.sharedDirector().getWinSize(); CCRotateBy rotate = CCRotateBy.actionWithDuration(10, 360); CCRepeatForever action = CCRepeatForever.actionWithAction(rotate); for (int i = 0; i < 3; i++) { CCSprite sprite = CCSprite.spriteWithFile("Images/grossini"); sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2)); CCSprite point = CCSprite.spriteWithFile("Images/r1"); point.scale = 0.25f; point.position = sprite.position; addChild(point, 10, 100 + i); switch (i) { case 0: sprite.anchorPoint = new CCPoint(0, 0); break; case 1: sprite.anchorPoint = (new CCPoint(0.5f, 0.5f)); break; case 2: sprite.anchorPoint = (new CCPoint(1, 1)); break; } point.position = (sprite.position); CCRepeatForever copy = (CCRepeatForever)action.copy(); sprite.runAction(copy); addChild(sprite, i); } }
public SpriteAnchorPoint() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCActionInterval rotate = CCRotateBy.actionWithDuration(10, 360); CCAction action = CCRepeatForever.actionWithAction(rotate); for (int i = 0; i < 3; i++) { CCSprite sprite = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * i, 121 * 1, 85, 121)); sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2)); CCSprite point = CCSprite.spriteWithFile("Images/r1"); point.scale = 0.25f; point.position = (sprite.position); addChild(point, 10); switch (i) { case 0: sprite.anchorPoint = (new CCPoint(0, 0)); break; case 1: sprite.anchorPoint = (new CCPoint(0.5f, 0.5f)); break; case 2: sprite.anchorPoint = (new CCPoint(1, 1)); break; } point.position = sprite.position; CCAction copy = (CCAction)(action.copy()); sprite.runAction(copy); addChild(sprite, i); } }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1); CCSprite sp2 = CCSprite.spriteWithFile(TestResource.s_pPathSister2); CCSprite sp3 = CCSprite.spriteWithFile(TestResource.s_pPathSister1); CCSprite sp4 = CCSprite.spriteWithFile(TestResource.s_pPathSister2); sp1.position = (new CCPoint(100, s.height / 2)); sp2.position = (new CCPoint(380, s.height / 2)); addChild(sp1); addChild(sp2); sp3.scale = (0.25f); sp4.scale = (0.25f); sp1.addChild(sp3); sp2.addChild(sp4); CCActionInterval a1 = CCRotateBy.actionWithDuration(2, 360); CCActionInterval a2 = CCScaleBy.actionWithDuration(2, 2); CCAction action1 = CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(a1, a2, a2.reverse())) ); CCAction action2 = CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions( (CCActionInterval)(a1.copy()), (CCActionInterval)(a2.copy()), a2.reverse())) ); sp2.anchorPoint = (new CCPoint(0, 0)); sp1.runAction(action1); sp2.runAction(action2); }
public override void onEnter() { base.onEnter(); CCSprite child = CCSprite.spriteWithFile(s_pPathGrossini); child.position = (new CCPoint(200, 200)); addChild(child, 1); //Sum of all action's duration is 1.5 second. child.runAction(CCRotateBy.actionWithDuration(1.5f, 90)); child.runAction(CCSequence.actions( CCDelayTime.actionWithDuration(1.4f), CCFadeOut.actionWithDuration(1.1f)) ); //After 1.5 second, self will be removed. runAction(CCSequence.actions( CCDelayTime.actionWithDuration(1.4f), CCCallFunc.actionWithTarget(this, (removeThis))) ); }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF l = CCLabelTTF.labelWithString("Grossini only rotate/scale in 3 seconds", "Arial", 16); addChild(l); l.position = (new CCPoint(s.width / 2, 245)); CCSprite pGrossini = CCSprite.spriteWithFile(s_pPathGrossini); addChild(pGrossini, 0, (int)KTag.kTagGrossini); pGrossini.position = new CCPoint(s.width / 2, s.height / 2); pGrossini.runAction(CCScaleBy.actionWithDuration(2, 2)); CCActionManager.sharedManager().pauseTarget(pGrossini); pGrossini.runAction(CCRotateBy.actionWithDuration(2, 360)); this.schedule(resumeGrossini, 3.0f); }
void shouldNotCrash(float dt) { unschedule((shouldNotCrash)); CCSize s = CCDirector.sharedDirector().getWinSize(); // if the node has timers, it crashes CCNode explosion = CCParticleSun.node(); ((CCParticleSun)explosion).Texture = (CCTextureCache.sharedTextureCache().addImage("Images/fire")); // if it doesn't, it works Ok. // CocosNode *explosion = [Sprite spriteWithFile:@"grossinis_sister2.png"); explosion.position = new CCPoint(s.width / 2, s.height / 2); runAction(CCSequence.actions( CCRotateBy.actionWithDuration(2, 360), CCCallFuncN.actionWithTarget(this, (removeMe)) )); addChild(explosion); }