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 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); m_tamara.Opacity = 0; CCActionInterval action1 = CCFadeIn.actionWithDuration(1.0f); CCFiniteTimeAction action1Back = action1.reverse(); CCActionInterval action2 = CCFadeOut.actionWithDuration(1.0f); CCFiniteTimeAction action2Back = action2.reverse(); m_tamara.runAction(CCSequence.actions(action1, action1Back)); m_kathia.runAction(CCSequence.actions(action2, action2Back)); }
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 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 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 MainLayer() { base.isTouchEnabled = true; CCSprite sprite = CCSprite.spriteWithFile(ClickAndMoveTest.s_pPathGrossini); CCLayer layer = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 0, 255)); addChild(layer, -1); addChild(sprite, 0, ClickAndMoveTest.kTagSprite); sprite.position = new CCPoint(20, 150); sprite.runAction(CCJumpTo.actionWithDuration(4, new CCPoint(300, 48), 100, 4)); layer.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions( CCFadeIn.actionWithDuration(1), CCFadeOut.actionWithDuration(1))) )); }
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(); centerSprites(3); CCFiniteTimeAction action = CCSequence.actions( CCMoveBy.actionWithDuration(2, new CCPoint(200, 0)), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(callback1))); CCFiniteTimeAction action2 = CCSequence.actions( CCScaleBy.actionWithDuration(2, 2), CCFadeOut.actionWithDuration(2), CCCallFuncN.actionWithTarget(this, new SEL_CallFuncN(callback2))); CCFiniteTimeAction action3 = CCSequence.actions( CCRotateBy.actionWithDuration(3, 360), CCFadeOut.actionWithDuration(2), CCCallFuncND.actionWithTarget(this, new SEL_CallFuncND(callback3), (object)0xbebabeba)); m_grossini.runAction(action); m_tamara.runAction(action2); m_kathia.runAction(action3); }