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)); }
public override void onEnter() { base.onEnter(); m_pInScene.Scale = 0.001f; m_pOutScene.Scale = 1.0f; m_pInScene.AnchorPoint = new CCPoint(0.5f, 0.5f); m_pOutScene.AnchorPoint = new CCPoint(0.5f, 0.5f); CCActionInterval rotozoom = (CCActionInterval)(CCSequence.actions ( CCSpawn.actions ( CCScaleBy.actionWithDuration(m_fDuration / 2, 0.001f), CCRotateBy.actionWithDuration(m_fDuration / 2, 360 * 2) ), CCDelayTime.actionWithDuration(m_fDuration / 2) )); m_pOutScene.RunAction(rotozoom); m_pInScene.RunAction ( CCSequence.actions ( rotozoom.Reverse(), CCCallFunc.actionWithTarget(this, (base.finish)) ) ); }
public SpriteBatchNodeChildren() { CCSize s = CCDirector.SharedDirector.WinSize; // parents CCSpriteBatchNode batch = CCSpriteBatchNode.Create("animations/grossini", 50); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist"); CCSprite sprite1 = new CCSprite("grossini_dance_01.png"); sprite1.Position = (new CCPoint(s.Width / 3, s.Height / 2)); CCSprite sprite2 = new CCSprite("grossini_dance_02.png"); sprite2.Position = (new CCPoint(50, 50)); CCSprite sprite3 = new CCSprite("grossini_dance_03.png"); sprite3.Position = (new CCPoint(-50, -50)); batch.AddChild(sprite1); sprite1.AddChild(sprite2); sprite1.AddChild(sprite3); // BEGIN NEW CODE var animFrames = new List<CCSpriteFrame>(); string str = ""; for (int i = 1; i < 15; i++) { string temp = ""; if (i<10) { temp = "0" + i; } else { temp = i.ToString(); } str = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str); animFrames.Add(frame); } CCAnimation animation = CCAnimation.Create(animFrames, 0.2f); sprite1.RunAction(new CCRepeatForever (new CCAnimate (animation))); // END NEW CODE CCActionInterval action = new CCMoveBy (2, new CCPoint(200, 0)); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval action_rot = new CCRotateBy (2, 360); CCActionInterval action_s = new CCScaleBy(2, 2); CCActionInterval action_s_back = (CCActionInterval)action_s.Reverse(); CCActionInterval seq2 = (CCActionInterval)action_rot.Reverse(); sprite2.RunAction(new CCRepeatForever (seq2)); sprite1.RunAction((CCAction)(new CCRepeatForever (action_rot))); sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(action, action_back))))); sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(action_s, action_s_back))))); }
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 static new CCScaleBy actionWithDuration(float duration, float sx, float sy) { CCScaleBy cCScaleBy = new CCScaleBy(); cCScaleBy.initWithDuration(duration, sx, sy); return(cCScaleBy); }
public SpriteBatchNodeAliased() { CCSpriteBatchNode batch = CCSpriteBatchNode.Create("Images/grossini_dance_atlas", 10); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sprite1 = new CCSprite(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 = new CCSprite(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 = new CCScaleBy(2, 5); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.FromActions(scale, scale_back)); CCAction repeat = new CCRepeatForever (seq); CCAction repeat2 = (CCAction)(repeat.Copy()); sprite1.RunAction(repeat); sprite2.RunAction(repeat2); }
/// <summary> /// creates the action with and X factor and a Y factor /// </summary> /// <param name="duration"></param> /// <param name="sx"></param> /// <param name="sy"></param> /// <returns></returns> public static new CCScaleBy actionWithDuration(float duration, float sx, float sy) { CCScaleBy pScaleBy = new CCScaleBy(); pScaleBy.initWithDuration(duration, sx, sy); //pScaleBy->autorelease(); return pScaleBy; }
/// <summary> /// creates the action with and X factor and a Y factor /// </summary> /// <param name="duration"></param> /// <param name="sx"></param> /// <param name="sy"></param> /// <returns></returns> public new static CCScaleBy actionWithDuration(float duration, float sx, float sy) { CCScaleBy pScaleBy = new CCScaleBy(); pScaleBy.initWithDuration(duration, sx, sy); //pScaleBy->autorelease(); return(pScaleBy); }
public TextLayer() { InitWithColor(CCTypes.CreateColor(32, 32, 32, 255)); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCNode node = new CCNode (); CCActionInterval effect = getAction(); node.RunAction(effect); AddChild(node, 0, EffectTestScene.kTagBackground); CCSprite bg = new CCSprite(TestResource.s_back3); node.AddChild(bg, 0); bg.AnchorPoint = new CCPoint(0.5f, 0.5f); bg.Position = new CCPoint(size.Width / 2, size.Height / 2); CCSprite grossini = new CCSprite(TestResource.s_pPathSister2); node.AddChild(grossini, 1); grossini.Position = new CCPoint(x / 3, y / 2); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back)))); //grossini.runAction(effect); CCSprite tamara = new CCSprite(TestResource.s_pPathSister1); node.AddChild(tamara, 1); tamara.Position = new CCPoint(2 * x / 3, y / 2); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32); label.Position = new CCPoint(x / 2, y - 80); AddChild(label); label.Tag = EffectTestScene.kTagLabel; CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); CCMenu menu = new CCMenu(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); Schedule(checkAnim); }
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 override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCSprite bg = new CCSprite("Images/background3"); AddChild(bg, 0, EffectAdvanceScene.kTagBackground); bg.Position = new CCPoint(x / 2, y / 2); grossini = new CCSprite("Images/grossinis_sister2"); bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1); grossini.Position = new CCPoint(x / 3.0f, 200); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back)))); tamara = new CCSprite("Images/grossinis_sister1"); bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2); tamara.Position = new CCPoint(2 * x / 3.0f, 200); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(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 = new CCLabelTTF(strSubtitle, "arial", 16); AddChild(l, 101); l.Position = new CCPoint(size.Width / 2, size.Height - 80); } CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback); CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback); CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback); CCMenu menu = CCMenu.Create(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 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); }
private void performanceActions(CCSprite pSprite) { CCSize size = CCDirector.SharedDirector.WinSize; pSprite.Position = new CCPoint((Random.Next() % (int) size.Width), (Random.Next() % (int) size.Height)); float period = 0.5f + (Random.Next() % 1000) / 500.0f; CCRotateBy rot = new CCRotateBy (period, 360.0f * Random.Float_0_1()); var rot_back = rot.Reverse(); CCAction permanentRotation = new CCRepeatForever (CCSequence.FromActions(rot, rot_back)); pSprite.RunAction(permanentRotation); float growDuration = 0.5f + (Random.Next() % 1000) / 500.0f; CCActionInterval grow = new CCScaleBy(growDuration, 0.5f, 0.5f); CCAction permanentScaleLoop = new CCRepeatForever (new CCSequence (grow, grow.Reverse())); pSprite.RunAction(permanentScaleLoop); }
public override CCObject copyWithZone(CCZone pZone) { CCScaleTo cCScaleBy = null; if (pZone == null || pZone.m_pCopyObject == null) { cCScaleBy = new CCScaleBy(); pZone = new CCZone(cCScaleBy); } else { cCScaleBy = (CCScaleBy)pZone.m_pCopyObject; } base.copyWithZone(pZone); cCScaleBy.initWithDuration(this.m_fDuration, this.m_fEndScaleX, this.m_fEndScaleY); return(cCScaleBy); }
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.Create("Images/grossini_dance_atlas", 1); AddChild(batch, 0, kTagSpriteBatchNode); batch.IgnoreAnchorPointForPosition = true; CCSize s = CCDirector.SharedDirector.WinSize; batch.AnchorPoint = new CCPoint(0.5f, 0.5f); batch.ContentSize = (new CCSize(s.Width, s.Height)); // SpriteBatchNode actions CCActionInterval rotate = new CCRotateBy (5, 360); CCAction action = new CCRepeatForever (rotate); // SpriteBatchNode actions CCActionInterval rotate_back = (CCActionInterval)rotate.Reverse(); CCActionInterval rotate_seq = (CCActionInterval)(CCSequence.FromActions(rotate, rotate_back)); CCAction rotate_forever = new CCRepeatForever (rotate_seq); CCActionInterval scale = new CCScaleBy(5, 1.5f); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCActionInterval scale_seq = (CCActionInterval)(CCSequence.FromActions(scale, scale_back)); CCAction scale_forever = new CCRepeatForever (scale_seq); float step = s.Width / 4; for (int i = 0; i < 3; i++) { CCSprite sprite = new CCSprite(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(); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2); CCSprite sp3 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp4 = new CCSprite(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 = new CCRotateBy (2, 360); CCActionInterval a2 = new CCScaleBy(2, 2); CCAction action1 = new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(a1, a2, a2.Reverse()) ); CCAction action2 = new CCRepeatForever ((CCActionInterval) (CCSequence.FromActions( (CCActionInterval) (a1.Copy()), (CCActionInterval) (a2.Copy()), a2.Reverse())) ); sp2.AnchorPoint = (new CCPoint(0, 0)); sp1.RunAction(action1); sp2.RunAction(action2); }
public override CCObject copyWithZone(CCZone pZone) { CCZone pNewZone = null; CCScaleTo pCopy = null; if (pZone != null && pZone.m_pCopyObject != null) { //in case of being called at sub class pCopy = (CCScaleBy)(pZone.m_pCopyObject); } else { pCopy = new CCScaleBy(); pZone = pNewZone = new CCZone(pCopy); } base.copyWithZone(pZone); pCopy.initWithDuration(m_fDuration, m_fEndScaleX, m_fEndScaleY); //CC_SAFE_DELETE(pNewZone); return(pCopy); }
public override CCObject copyWithZone(CCZone pZone) { CCZone pNewZone = null; CCScaleTo pCopy = null; if (pZone != null && pZone.m_pCopyObject != null) { //in case of being called at sub class pCopy = (CCScaleBy)(pZone.m_pCopyObject); } else { pCopy = new CCScaleBy(); pZone = pNewZone = new CCZone(pCopy); } base.copyWithZone(pZone); pCopy.initWithDuration(m_fDuration, m_fEndScaleX, m_fEndScaleY); //CC_SAFE_DELETE(pNewZone); return pCopy; }
public override void OnEnter() { base.OnEnter(); CCSize size = CCDirector.SharedDirector.WinSize; // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. var sprite = new CCSprite("Images/pattern1.png", new CCRect(0, 0, 512, 256)); AddChild(sprite, -1, (int)enumTag.kTagSprite1); sprite.Position = new CCPoint(size.Width/2,size.Height/2); #if OPENGL sprite.Texture.TexParameters = new CCTexParams() { MagFilter = (uint)All.Linear, MinFilter = (uint)All.Linear, WrapS = (uint)All.ClampToEdge, WrapT = (uint)All.ClampToEdge }; #else sprite.Texture.SamplerState = SamplerState.LinearClamp; #endif var rotate = new CCRotateBy(4, 360); sprite.RunAction(rotate); var scale = new CCScaleBy(2, 0.04f); var scaleBack = (CCScaleBy)scale.Reverse(); var seq = new CCSequence(scale, scaleBack); sprite.RunAction(seq); }
public TileMapTest() { CCTileMapAtlas map = CCTileMapAtlas.Create(s_TilesPng, s_LevelMapTga, 16, 16); // Convert it to "alias" (GL_LINEAR filtering) map.Texture.SetAntiAliasTexParameters(); CCSize s = map.ContentSize; CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height); // If you are not going to use the Map, you can free it now // NEW since v0.7 map.ReleaseMap(); AddChild(map, 0, kTagTileMap); map.AnchorPoint = (new CCPoint(0, 0.5f)); CCScaleBy scale = new CCScaleBy(4, 0.8f); CCFiniteTimeAction scaleBack = scale.Reverse(); var seq = CCSequence.FromActions(scale, scaleBack); map.RunAction(new CCRepeatForever ((CCActionInterval)seq)); }
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 TMXOrthoFromXMLTest() { CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test1"); AddChild(map, 0, kTagTileMap); /* object* pObj = NULL; CCARRAY_FOREACH(map.getChildren(), pObj) { CCSpriteBatchNode* child = (CCSpriteBatchNode*) pObj; child.Texture.setAntiAliasTexParameters(); } */ CCScaleBy action = new CCScaleBy(2, 0.5f); map.RunAction(action); }
public override CCFiniteTimeAction reverse() { return(CCScaleBy.actionWithDuration(this.m_fDuration, 1f / this.m_fEndScaleX, 1f / this.m_fEndScaleY)); }
public override void OnEnter() { base.OnEnter(); centerSprites(3); var actionTo = new CCScaleTo(2, 0.5f); var actionBy = new CCScaleBy(2, 1, 10); var actionBy2 = new CCScaleBy(2, 5f, 1.0f); var actionByBack = actionBy.Reverse(); m_grossini.RunAction(actionTo); m_tamara.RunAction(CCSequence.FromActions(actionBy, actionBy.Reverse())); m_kathia.RunAction(CCSequence.FromActions(actionBy2, actionBy2.Reverse())); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; // // Sprite 1: GL_LINEAR // // Default filter is GL_LINEAR CCSprite sprite = new CCSprite("Images/grossinis_sister1"); sprite.Position = new CCPoint( s.Width/3.0f, s.Height/2.0f); AddChild(sprite); // this is the default filterting sprite.Texture.SetAntiAliasTexParameters(); // // Sprite 1: GL_NEAREST // CCSprite sprite2 = new CCSprite("Images/grossinis_sister2"); sprite2.Position = new CCPoint(2*s.Width/3.0f, s.Height/2.0f); AddChild(sprite2); // Use Nearest in this one sprite2.Texture.SetAliasTexParameters(); // scale them to show CCScaleBy sc = new CCScaleBy(3, 8.0f); CCScaleBy sc_back = (CCScaleBy) (sc.Reverse()); CCRepeatForever scaleforever = new CCRepeatForever ((CCActionInterval) (CCSequence.FromActions(sc, sc_back))); CCRepeatForever scaleToo = (CCRepeatForever) (scaleforever.Copy()); sprite2.RunAction(scaleforever); sprite.RunAction(scaleToo); CCTextureCache.SharedTextureCache.DumpCachedTextureInfo(); }
public SpriteBatchNodeOffsetAnchorScale() { CCSize s = CCDirector.SharedDirector.WinSize; for (int i = 0; i < 3; i++) { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFramesWithFile("animations/grossini.plist"); cache.AddSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray"); // // Animation using Sprite BatchNode // CCSprite sprite = new CCSprite("grossini_dance_01.png"); sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2)); CCSprite point = new CCSprite("Images/r1"); point.Scale = 0.25f; point.Position = sprite.Position; AddChild(point, 200); 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; CCSpriteBatchNode spritesheet = new CCSpriteBatchNode("animations/grossini"); AddChild(spritesheet); var animFrames = new List<CCSpriteFrame>(14); string str = ""; for (int k = 0; k < 14; k++) { string temp = ""; if (k+1<10) { temp = "0" + (k + 1); } else { temp = (k + 1).ToString(); } str = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = cache.SpriteFrameByName(str); animFrames.Add(frame); } CCAnimation animation = new CCAnimation(animFrames, 0.3f); sprite.RunAction(new CCRepeatForever (new CCAnimate (animation))); CCActionInterval scale = new CCScaleBy(2, 2); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCActionInterval seq_scale = (CCActionInterval)(CCSequence.FromActions(scale, scale_back)); sprite.RunAction(new CCRepeatForever (seq_scale)); spritesheet.AddChild(sprite, i); //animFrames->release(); // win32 : memory leak 2010-0415 } }
public override void onEnter() { base.onEnter(); this.m_pInScene.scale = 0.001f; this.m_pOutScene.scale = 1f; this.m_pInScene.anchorPoint = new CCPoint(0.5f, 0.5f); this.m_pOutScene.anchorPoint = new CCPoint(0.5f, 0.5f); CCFiniteTimeAction[] cCFiniteTimeActionArray = new CCFiniteTimeAction[2]; CCFiniteTimeAction[] cCFiniteTimeActionArray1 = new CCFiniteTimeAction[] { CCScaleBy.actionWithDuration(this.m_fDuration / 2f, 0.001f), CCRotateBy.actionWithDuration(this.m_fDuration / 2f, 720f) }; cCFiniteTimeActionArray[0] = CCSpawn.actions(cCFiniteTimeActionArray1); cCFiniteTimeActionArray[1] = CCDelayTime.actionWithDuration(this.m_fDuration / 2f); CCActionInterval cCActionInterval = (CCActionInterval)CCSequence.actions(cCFiniteTimeActionArray); this.m_pOutScene.runAction(cCActionInterval); CCScene mPInScene = this.m_pInScene; CCFiniteTimeAction[] cCFiniteTimeActionArray2 = new CCFiniteTimeAction[] { cCActionInterval.reverse(), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.finish)) }; mPInScene.runAction(CCSequence.actions(cCFiniteTimeActionArray2)); }
public SpriteOffsetAnchorSkewScale() { CCSize s = CCDirector.SharedDirector.WinSize; for (int i = 0; i < 3; i++) { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFramesWithFile("animations/grossini.plist"); cache.AddSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray"); // // Animation using Sprite batch // CCSprite sprite = new CCSprite("grossini_dance_01.png"); sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2)); CCSprite point = new CCSprite("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; var animFrames = new List<CCSpriteFrame>(); string tmp = ""; for (int j = 0; j < 14; j++) { tmp = string.Format("grossini_dance_{0:00}.png", j + 1); CCSpriteFrame frame = cache.SpriteFrameByName(tmp); animFrames.Add(frame); } CCAnimation animation = CCAnimation.Create(animFrames, 0.3f); sprite.RunAction(new CCRepeatForever (new CCAnimate (animation))); animFrames = null; // Skew CCSkewBy skewX = new CCSkewBy (2, 45, 0); CCActionInterval skewX_back = (CCActionInterval)skewX.Reverse(); CCSkewBy skewY = new CCSkewBy (2, 0, 45); CCActionInterval skewY_back = (CCActionInterval)skewY.Reverse(); CCFiniteTimeAction seq_skew = CCSequence.FromActions(skewX, skewX_back, skewY, skewY_back); sprite.RunAction(new CCRepeatForever ((CCActionInterval)seq_skew)); // Scale CCScaleBy scale = new CCScaleBy(2, 2); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCFiniteTimeAction seq_scale = CCSequence.FromActions(scale, scale_back); sprite.RunAction(new CCRepeatForever ((CCActionInterval)seq_scale)); AddChild(sprite, 0); } }