public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer1 = new CCLayerColor(new CCColor4B(255, 255, 0, 80), 100, 300); layer1.Position = (new CCPoint(s.Width / 3, s.Height / 2)); layer1.IgnoreAnchorPointForPosition = false; AddChild(layer1, 1); CCLayerColor layer2 = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 100, 300); layer2.Position = (new CCPoint((s.Width / 3) * 2, s.Height / 2)); layer2.IgnoreAnchorPointForPosition = false; AddChild(layer2, 1); CCActionInterval actionTint = new CCTintBy (2, -255, -127, 0); CCActionInterval actionTintBack = (CCActionInterval)actionTint.Reverse(); CCActionInterval seq1 = (CCActionInterval)CCSequence.FromActions(actionTint, actionTintBack); layer1.RunAction(seq1); CCActionInterval actionFade = new CCFadeOut (2.0f); CCActionInterval actionFadeBack = (CCActionInterval)actionFade.Reverse(); CCActionInterval seq2 = (CCActionInterval)CCSequence.FromActions(actionFade, actionFadeBack); layer2.RunAction(seq2); }
public void addNewSpriteWithCoords(CCPoint p) { int idx = (int)(CCMacros.CCRandomBetween0And1() * 1400.0f / 100.0f); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(x, y, 85, 121)); AddChild(sprite); sprite.Position = p; CCActionInterval action; float random = CCMacros.CCRandomBetween0And1(); if (random < 0.20) action = new CCScaleBy(3, 2); else if (random < 0.40) action = new CCRotateBy (3, 360); else if (random < 0.60) action = new CCBlink (1, 3); else if (random < 0.8) action = new CCTintBy (2, 0, -255, -255); else action = new CCFadeOut (2); object obj = action.Reverse(); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.FromActions(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
// CCLayer public override void onEnter() { base.onEnter(); m_nCharLimit = 12; m_pTextFieldAction = CCRepeatForever.actionWithAction( (CCActionInterval)CCSequence.actions( CCFadeOut.actionWithDuration(0.25f), CCFadeIn.actionWithDuration(0.25f))); //m_pTextFieldAction->retain(); m_bAction = false; // add CCTextFieldTTF CCSize s = CCDirector.sharedDirector().getWinSize(); m_pTextField = CCTextFieldTTF.textFieldWithPlaceHolder("<click here for input>", TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE); addChild(m_pTextField); //m_pTextField.setDelegate(this); //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // // on android, CCTextFieldTTF cannot auto adjust its position when soft-keyboard pop up // // so we had to set a higher position // m_pTextField->setPosition(new CCPoint(s.width / 2, s.height/2 + 50)); //#else // m_pTextField->setPosition(ccp(s.width / 2, s.height / 2)); //#endif m_pTrackNode = m_pTextField; }
public void addNewSprite() { CCSize s = CCDirector.SharedDirector.WinSize; CCPoint p = new CCPoint((float)(Random.NextDouble() * s.Width), (float)(Random.NextDouble() * s.Height)); CCSpriteBatchNode batch = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode); int idx = (int)(Random.NextDouble() * 1400 / 100); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = new CCSprite(batch.Texture, new CCRect(x, y, 85, 121)); batch.AddChild(sprite); sprite.Position = (new CCPoint(p.X, p.Y)); CCActionInterval action; float random = (float)Random.NextDouble(); if (random < 0.20) action = new CCScaleBy(3, 2); else if (random < 0.40) action = new CCRotateBy (3, 360); else if (random < 0.60) action = new CCBlink (1, 3); else if (random < 0.8) action = new CCTintBy (2, 0, -255, -255); else action = new CCFadeOut (2); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.FromActions(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
public LabelAtlasColorTest() { CCLabelAtlas label1 = CCLabelAtlas.labelWithString("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label1, 0, (int)TagSprite.kTagSprite1); label1.position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = CCLabelAtlas.labelWithString("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label2, 0, (int)TagSprite.kTagSprite2); label2.position = new CCPoint(10, 200); //label2.setColor( ccRED ); label2.Color = ccRED; CCActionInterval fade = CCFadeOut.actionWithDuration(1.0f); //CCActionInterval fade_in = fade.reverse(); CCActionInterval fade_in = null; CCFiniteTimeAction seq = CCSequence.actions(fade, fade_in, null); CCAction repeat = CCRepeatForever.actionWithAction((CCActionInterval)seq); label2.runAction(repeat); m_time = 0; //schedule( schedule_selector(LabelAtlasColorTest.step) ); //:@selector(step:)]; }
public static new CCFadeOut actionWithDuration(float d) { CCFadeOut cCFadeOut = new CCFadeOut(); cCFadeOut.initWithDuration(d); return(cCFadeOut); }
public static CCFadeOut actionWithDuration(float d) { CCFadeOut pAction = new CCFadeOut(); pAction.initWithDuration(d); return pAction; }
public static CCFadeOut actionWithDuration(float d) { CCFadeOut pAction = new CCFadeOut(); pAction.initWithDuration(d); return(pAction); }
public Atlas4() { m_time = 0; // Upper Label CCLabelBMFont label = CCLabelBMFont.labelWithString("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); 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(1); 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); //CCActionInterval scale_back = scale.reverse(); CCActionInterval scale_back = null; CCFiniteTimeAction scale_seq = CCSequence.actions(scale, scale_back, null); 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, null); 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/bitmapFontTest.fnt"); 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 Atlas4() { m_time = 0; // Upper Label CCLabelBMFont label = CCLabelBMFont.Create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); AddChild(label); CCSize s = CCDirector.SharedDirector.WinSize; 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 = new CCRotateBy (2, 360); CCAction rot_4ever = new CCRepeatForever (rotate); CCActionInterval scale = new CCScaleBy(2, 1.5f); CCFiniteTimeAction scale_back = scale.Reverse(); CCFiniteTimeAction scale_seq = CCSequence.FromActions(scale, scale_back); CCAction scale_4ever = new CCRepeatForever ((CCActionInterval)scale_seq); CCActionInterval jump = new CCJumpBy (0.5f, new CCPoint(), 60, 1); CCAction jump_4ever = new CCRepeatForever (jump); CCActionInterval fade_out = new CCFadeOut (1); CCActionInterval fade_in = new CCFadeIn (1); CCFiniteTimeAction seq = CCSequence.FromActions(fade_out, fade_in); CCAction fade_4ever = new CCRepeatForever ((CCActionInterval)seq); BChar.RunAction(rot_4ever); BChar.RunAction(scale_4ever); FChar.RunAction(jump_4ever); AChar.RunAction(fade_4ever); // Bottom Label CCLabelBMFont label2 = CCLabelBMFont.Create("00.0", "fonts/bitmapFontTest.fnt"); 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 virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen) { // if insert enter, treat as default to detach with ime if ("\n" == text) { return(false); } // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore. if (pSender.CharCount >= m_nCharLimit) { return(true); } // create a insert text sprite and do some action CCLabelTTF label = CCLabelTTF.labelWithString(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE); this.addChild(label); ccColor3B color = new ccColor3B { r = 226, g = 121, b = 7 }; label.Color = color; // move the sprite from top to position CCPoint endPos = pSender.position; if (pSender.CharCount > 0) { endPos.x += pSender.contentSize.width / 2; } CCSize inputTextSize = label.contentSize; CCPoint beginPos = new CCPoint(endPos.x, CCDirector.sharedDirector().getWinSize().height - inputTextSize.height * 2); float duration = 0.5f; label.position = beginPos; label.scale = 8; CCAction seq = CCSequence.actions( CCSpawn.actions( CCMoveTo.actionWithDuration(duration, endPos), CCScaleTo.actionWithDuration(duration, 1), CCFadeOut.actionWithDuration(duration)), CCCallFuncN.actionWithTarget(this, callbackRemoveNodeWhenDidAction)); label.runAction(seq); return(false); }
public override CCObject copyWithZone(CCZone pZone) { CCFadeOut cCFadeOut = null; if (pZone == null || pZone.m_pCopyObject == null) { cCFadeOut = new CCFadeOut(); pZone = new CCZone(cCFadeOut); } else { cCFadeOut = (CCFadeOut)pZone.m_pCopyObject; } base.copyWithZone(pZone); return(cCFadeOut); }
public LabelTTFA8Test() { CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer = CCLayerColor.Create(new CCColor4B(128, 128, 128, 255)); AddChild(layer, -10); // CCLabelBMFont CCLabelTTF label1 = new CCLabelTTF("Testing A8 Format", "Marker Felt", 38); AddChild(label1); label1.Color = CCTypes.CCRed; label1.Position = new CCPoint(s.Width / 2, s.Height / 2); CCFadeOut fadeOut = new CCFadeOut (2); CCFadeIn fadeIn = new CCFadeIn (2); CCFiniteTimeAction seq = CCSequence.FromActions(fadeOut, fadeIn); CCRepeatForever forever = new CCRepeatForever ((CCActionInterval) seq); label1.RunAction(forever); }
public override CCObject copyWithZone(CCZone pZone) { CCZone pNewZone = null; CCFadeOut pCopy = null; if(pZone != null && pZone.m_pCopyObject != null) { //in case of being called at sub class pCopy = (CCFadeOut)(pZone.m_pCopyObject); } else { pCopy = new CCFadeOut(); pZone = pNewZone = new CCZone(pCopy); } base.copyWithZone(pZone); return pCopy; }
public override CCObject copyWithZone(CCZone pZone) { CCZone pNewZone = null; CCFadeOut pCopy = null; if (pZone != null && pZone.m_pCopyObject != null) { //in case of being called at sub class pCopy = (CCFadeOut)(pZone.m_pCopyObject); } else { pCopy = new CCFadeOut(); pZone = pNewZone = new CCZone(pCopy); } base.copyWithZone(pZone); return(pCopy); }
public Atlas3() { m_time = 0; CCLayerColor col = new CCLayerColor(new CCColor4B(128, 128, 128, 255)); AddChild(col, -10); CCLabelBMFont label1 = CCLabelBMFont.Create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label1.AnchorPoint = new CCPoint(0, 0); AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); CCActionInterval fade = new CCFadeOut (1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in); CCAction repeat = new CCRepeatForever ((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.Create("Test", "fonts/bitmapFontTest2.fnt"); // 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.Create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label3.AnchorPoint = new CCPoint(1, 1); AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); CCSize s = CCDirector.SharedDirector.WinSize; 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(); CCLayerColor l = CCLayerColor.layerWithColor(m_tColor); m_pInScene.visible = false; addChild(l, 2, kSceneFade); CCNode f = getChildByTag(kSceneFade); CCActionInterval a = (CCActionInterval)CCSequence.actions ( CCFadeIn.actionWithDuration(m_fDuration / 2), CCCallFunc.actionWithTarget(this, (base.hideOutShowIn)), CCFadeOut.actionWithDuration(m_fDuration / 2), CCCallFunc.actionWithTarget(this, (base.finish)) ); f.runAction(a); }
public LabelAtlasColorTest() { CCLabelAtlas label1 = CCLabelAtlas.Create("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label1, 0, (int)TagSprite.kTagSprite1); label1.Position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = CCLabelAtlas.Create("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label2, 0, (int)TagSprite.kTagSprite2); label2.Position = new CCPoint(10, 200); label2.Color = ccRED; CCActionInterval fade = new CCFadeOut (1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in); CCAction repeat = new CCRepeatForever ((CCActionInterval)seq); label2.RunAction(repeat); m_time = 0; Schedule(step); //:@selector(step:)]; }
public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen) { // create a delete text sprite and do some action CCLabelTTF label = CCLabelTTF.labelWithString(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE); this.addChild(label); // move the sprite to fly out CCPoint beginPos = pSender.position; CCSize textfieldSize = pSender.contentSize; CCSize labelSize = label.contentSize; beginPos.x += (textfieldSize.width - labelSize.width) / 2.0f; int RAND_MAX = 32767; Random rand = new Random(); CCSize winSize = CCDirector.sharedDirector().getWinSize(); CCPoint endPos = new CCPoint(-winSize.width / 4.0f, winSize.height * (0.5f + (float)rand.Next() / (2.0f * RAND_MAX))); float duration = 1; float rotateDuration = 0.2f; int repeatTime = 5; label.position = beginPos; CCAction seq = CCSequence.actions( CCSpawn.actions( CCMoveTo.actionWithDuration(duration, endPos), CCRepeat.actionWithAction( CCRotateBy.actionWithDuration(rotateDuration, (rand.Next() % 2 > 0) ? 360 : -360), (uint)repeatTime), CCFadeOut.actionWithDuration(duration)), CCCallFuncN.actionWithTarget(this, callbackRemoveNodeWhenDidAction)); label.runAction(seq); return(false); }
public override CCFiniteTimeAction reverse() { return(CCFadeOut.actionWithDuration(this.m_fDuration)); }
public override void onEnter() { base.onEnter(); CCLayerColor cCLayerColor = CCLayerColor.layerWithColor(this.m_tColor); this.m_pInScene.visible = false; this.addChild(cCLayerColor, 2, 2147483647); CCNode childByTag = base.getChildByTag(2147483647); CCFiniteTimeAction[] cCFiniteTimeActionArray = new CCFiniteTimeAction[] { CCFadeIn.actionWithDuration(this.m_fDuration / 2f), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.hideOutShowIn)), CCFadeOut.actionWithDuration(this.m_fDuration / 2f), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.finish)) }; childByTag.runAction((CCActionInterval)CCSequence.actions(cCFiniteTimeActionArray)); }
public override CCFiniteTimeAction Reverse() { return(CCFadeOut.actionWithDuration(Duration)); }
public TMXReadWriteTest() { m_gid = 0; CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test2"); AddChild(map, 0, kTagTileMap); 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)); //new CCPoint(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)); CCMoveBy move = new CCMoveBy (0.5f, new CCPoint(0, 160)); CCRotateBy rotate = new CCRotateBy (2, 360); CCScaleBy scale = new CCScaleBy(2, 5); CCFadeOut opacity = new CCFadeOut (2); CCFadeIn fadein = new CCFadeIn (2); CCScaleTo scaleback = new CCScaleTo(1, 1); CCCallFuncN finish = new CCCallFuncN(removeSprite); CCSequence seq0 = CCSequence.FromActions(move, rotate, scale, opacity, fadein, scaleback, finish); var seq1 = (CCActionInterval) (seq0.Copy()); var seq2 = (CCActionInterval) (seq0.Copy()); var 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 override void OnEnter() { base.OnEnter(); centerSprites(2); m_tamara.Opacity = 0; var action1 = new CCFadeIn (1.0f); var action1Back = action1.Reverse(); var action2 = new CCFadeOut (1.0f); var action2Back = action2.Reverse(); m_tamara.RunAction(CCSequence.FromActions(action1, action1Back)); m_kathia.RunAction(CCSequence.FromActions(action2, action2Back)); }