protected override void AddedToScene() { base.AddedToScene(); var s = VisibleBoundsWorldspace.Size; var left = new CCPoint(s.Width / 4, s.Height / 2); var right = new CCPoint(s.Width / 4 * 3, s.Height / 2); var sp1 = new CCSprite("Images/grossini.png"); sp1.Position = new CCPoint(left); var move1 = new CCMoveBy(1, new CCPoint(s.Width / 2, 0)); AddChild(sp1); sp1.RepeatForever(move1, move1.Reverse()); var sp2 = new CCSprite("Images/grossinis_sister1.png"); sp2.Position = new CCPoint(right); var move2 = new CCMoveBy(1, new CCPoint(-s.Width / 2, 0)); AddChild(sp2); sp2.RepeatForever(move2, move2.Reverse()); var label1 = new CCLabel("capture all", "fonts/arial", 24, CCLabelFormat.SpriteFont); var mi1 = new CCMenuItemLabel(label1, OnCapture); var menu = new CCMenu(mi1); AddChild(menu); menu.Position = new CCPoint(s.Width / 2, s.Height / 4); }
public StressTest2() { var sublayer = new CCLayer(); var sp1 = new CCSprite(TestResource.s_pPathSister1); var move = new CCMoveBy(3, new CCPoint(350, 0)); var move_ease_inout3 = new CCEaseInOut(move, 2.0f); var move_ease_inout_back3 = move_ease_inout3.Reverse(); var seq3 = new CCSequence(move_ease_inout3, move_ease_inout_back3); sp1.RepeatForever(seq3); sublayer.AddChild(sp1, 1, CocosNodeTestStaticLibrary.kTagSprite2); var fire = new CCParticleFire(CCPoint.Zero) { Tag = CocosNodeTestStaticLibrary.kTagSprite3 }; fire.Texture = (CCTextureCache.SharedTextureCache.AddImage("Images/fire")); fire.RepeatForever(seq3); sublayer.AddChild(fire, 2); Schedule(shouldNotLeak, 6.0f); AddChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1); }
public NodeToWorld3D() { // // This code tests that nodeToParent works OK: // - It tests different anchor Points // - It tests different children anchor points parent = new CCNode(); parent.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(parent); back = new CCSprite(TestResource.s_back3); parent.AddChild(back, -10); back.AnchorPoint = CCPoint.Zero; var item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect); menu = new CCMenu(item); menu.AlignItemsVertically(); back.AddChild(menu); item.RepeatForever(CocosNodeTestStaticLibrary.nodeRotate); back.RepeatForever(CocosNodeTestStaticLibrary.nodeMove, CocosNodeTestStaticLibrary.nodeMove.Reverse()); parent.RunAction(CocosNodeTestStaticLibrary.nodeOrbit); }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var sprite = new CCSprite("Images/grossinis_sister1.png"); sprite.Position = CCVisibleRect.Center; AddChild(sprite); sprite.RepeatForever(rotateBy); // Add a menu item to resume the Scheduled actions. CCMenuItemFont.FontSize = 32; CCMenuItemFont.FontName = "MarkerFelt"; var menu = new CCMenu( new CCMenuItemFont("Resume", resume) ); menu.AlignItemsVertically(4); menu.Position = new CCPoint(s.Width / 2, s.Height / 4); AddChild(menu); Schedule(); Schedule(tick1, 0.5f); Schedule(tick2, 1.0f); Schedule(pause, 3.0f, 0, 0); }
public override void OnEnter() { base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size; sprite.Position = new CCPoint(windowSize.Width / 2, windowSize.Height / 2); sprite.RepeatForever(seq); }
public TMXOrthoZorder() : base("TileMaps/orthogonal-test-zorder") { m_tamara = new CCSprite(pathSister1); tileLayersContainer.AddChild(m_tamara, tileMap.Children.Count); m_tamara.AnchorPoint = CCPoint.AnchorMiddleBottom; m_tamara.RepeatForever(move, back); Schedule(repositionSprite); }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255)); layer1.IsColorCascaded = false; layer1.Position = new CCPoint(0, s.Height / 2); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabel("Test", "fonts/bitmapFontTest.fnt"); // by default a CCLabelBMFont has IsColorModifiedByOpacity on by default if the // texture atlas is PreMultipliedAlpha. Label as used by Cocos2d-x by default has // this set to false. Maybe this is a bug in Cocos2d-x? label.IsColorModifiedByOpacity = false; layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild(layer1, 0, kTagLayer); sister1.Position = new CCPoint(s.Width * 1 / 3, 0); sister2.Position = new CCPoint(s.Width * 2 / 3, 0); label.Position = new CCPoint(s.Width / 2, 0); // Define our delay time var delay = new CCDelayTime(1); layer1.RepeatForever( new CCFadeTo(4, 0), new CCFadeTo(4, 255), delay ); // We only have to define them once. var fadeTo11 = new CCFadeTo(2, 0); var fadeTo12 = new CCFadeTo(2, 255); sister1.RepeatForever( fadeTo11, fadeTo12, fadeTo11, fadeTo12, delay ); // Enable cascading in scene SetEnableRecursiveCascading(this, true); }
public override void OnEnter() { base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size; var move = new CCMoveBy(10, Layer.ScreenToWorldspace(new CCPoint(400, 450))); var back = move.Reverse(); m_tamara.RepeatForever(move, back); Schedule(repositionSprite); }
public TMXIsoZorderFromStream() : base(new System.IO.StreamReader(CCFileUtils.GetFileStream("TileMaps/iso-test-zorder1.tmx"))) { m_tamara = new CCSprite(pathSister1); tileLayersContainer.AddChild(m_tamara, tileMap.Children.Count); tileLayersContainer.Position = new CCPoint(-50.0f, -50.0f); m_tamara.AnchorPoint = CCPoint.Zero; m_tamara.RepeatForever(move, back); Schedule(repositionSprite); }
public TMXIsoZorder() : base("TileMaps/iso-test-zorder") { m_tamara = new CCSprite(pathSister1); tileLayersContainer.AddChild(m_tamara, tileMap.Children.Count); tileLayersContainer.Position = new CCPoint(-50.0f, -50.0f); m_tamara.AnchorPoint = CCPoint.Zero; m_tamara.RepeatForever(move, back); Schedule(repositionSprite); }
public override void OnEnter() { CCRect visibleBounds = Layer.VisibleBoundsWorldspace; base.OnEnter(); bgNode = new CCNodeGrid(); bgNode.AnchorPoint = CCPoint.AnchorMiddle; contentLayer.AddChild(bgNode); //bgNode.Position = visibleBounds.Center; var bg = new CCSprite("Images/background3"); //bg.AnchorPoint = CCPoint.AnchorMiddle; bg.Position = visibleBounds.Center; //bgNode.ContentSize = bg.ContentSize; bgNode.AddChild(bg); Target1 = new CCNodeGrid(); Target1.AnchorPoint = CCPoint.AnchorMiddle; grossini = new CCSprite("Images/grossinis_sister2"); Target1.AddChild(grossini); bgNode.AddChild(Target1); Target1.Position = bg.BoundingBox.Center + new CCPoint(-100.0f, 0.0f); //grossini.Position = var sc = new CCScaleBy(2, 5); var sc_back = sc.Reverse(); Target1.RepeatForever(sc, sc_back); Target2 = new CCNodeGrid(); Target2.AnchorPoint = CCPoint.AnchorMiddle; tamara = new CCSprite("Images/grossinis_sister1"); Target2.AddChild(tamara); bgNode.AddChild(Target2); Target2.Position = bg.BoundingBox.Center + new CCPoint(100.0f, 0.0f); var sc2 = new CCScaleBy(2, 5); var sc2_back = sc2.Reverse(); tamara.RepeatForever(sc2, sc2_back); }
public override void OnEnter() { base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size; var sprite = (CCSprite)GetChildByTag((int)kTagSprite.kTagSprite1); sprite.IsAntialiased = false; sprite1.Position = new CCPoint(windowSize.Width / 2 - 100, windowSize.Height / 2); sprite2.Position = new CCPoint(windowSize.Width / 2 + 100, windowSize.Height / 2); sprite1.RepeatForever(seq); sprite2.RepeatForever(seq); }
public TMXOrthoZorder() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test-zorder"); AddChild(map, 0, kTagTileMap); m_tamara = new CCSprite(pathSister1); map.AddChild(m_tamara, map.Children.Count); m_tamara.AnchorPoint = CCPoint.AnchorMiddleBottom; m_tamara.RepeatForever(move, back); Schedule(repositionSprite); }
public override void OnEnter() { base.OnEnter(); var move = new CCMoveBy(10, new CCPoint(400, 450)); var back = move.Reverse(); m_tamara.RepeatForever(move, back); Schedule(repositionSprite); tileMap.Camera.NearAndFarOrthographicZClipping = new CCNearAndFarClipping(-2000f, 2000f); Window.IsUseDepthTesting = true; }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255)); layer1.IsColorCascaded = false; layer1.Position = new CCPoint(0, s.Height / 2); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabel("Test", "fonts/bitmapFontTest.fnt"); layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild(layer1, 0, kTagLayer); sister1.Position = new CCPoint(s.Width * 1 / 3, 0); sister2.Position = new CCPoint(s.Width * 2 / 3, 0); label.Position = new CCPoint(s.Width / 2, 0); // Define our delay time var delay = new CCDelayTime(1); layer1.RepeatForever( new CCTintTo(6, 255, 0, 255), new CCTintTo(6, 255, 255, 255), delay ); sister1.RepeatForever( new CCTintTo(2, 255, 255, 0), new CCTintTo(2, 255, 255, 255), new CCTintTo(2, 0, 255, 255), new CCTintTo(2, 255, 255, 255), new CCTintTo(2, 255, 0, 255), new CCTintTo(2, 255, 255, 255), delay ); // Enable cascading in scene SetEnableRecursiveCascading(this, true); }
protected override void AddedToScene() { base.AddedToScene(); var listener = new CCEventListenerTouchAllAtOnce(); listener.OnTouchesEnded = onTouchesEnded; AddEventListener(listener); CCSize s = Layer.VisibleBoundsWorldspace.Size; var rotate = new CCRotateBy(10, 360); for (int i = 0; i < 3; i++) { CCSprite sprite = new CCSprite("Images/grossini"); 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, 10, 100 + i); switch (i) { case 0: sprite.AnchorPoint = CCPoint.AnchorLowerLeft; break; case 1: sprite.AnchorPoint = CCPoint.AnchorMiddle; break; case 2: sprite.AnchorPoint = CCPoint.AnchorUpperRight; break; } point.Position = sprite.Position; sprite.RepeatForever(rotate); AddChild(sprite, i); } }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255)); layer1.IsColorCascaded = false; layer1.Position = new CCPoint(0, s.Height / 2); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabel("Test", "fonts/bitmapFontTest.fnt"); layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild(layer1, 0, kTagLayer); sister1.Position = new CCPoint(s.Width * 1 / 3, 0); sister2.Position = new CCPoint(s.Width * 2 / 3, 0); label.Position = new CCPoint(s.Width / 2, 0); // Define our delay time var delay = new CCDelayTime(1); layer1.RepeatForever( new CCFadeTo(4, 0), new CCFadeTo(4, 255), delay ); // We only have to define them once. var fadeTo11 = new CCFadeTo(2, 0); var fadeTo12 = new CCFadeTo(2, 255); sister1.RepeatForever( fadeTo11, fadeTo12, fadeTo11, fadeTo12, delay ); }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var sprite = new CCSprite("Images/grossinis_sister1.png"); sprite.Position = CCVisibleRect.Center; AddChild(sprite); sprite.RepeatForever(rotateBy); Schedule(tick1, 0.5f); Schedule(tick2, 1.0f); Schedule(tick3, 1.5f); Schedule(tick4, 1.5f); Schedule(unscheduleAll, 4); }
CCSprite AddBanana() { var spriteSheet = new CCSpriteSheet("animations/monkey.plist"); var banana = new CCSprite(spriteSheet.Frames.Find((x) => x.TextureFilename.StartsWith("Banana"))); var p = GetRandomPosition(banana.ContentSize); banana.Position = p; banana.Scale = 0.5f; AddChild(banana); var moveBanana = new CCMoveTo(5.0f, new CCPoint(banana.Position.X, 0)); banana.RunActions(moveBanana, moveBananaComplete); banana.RepeatForever(rotateBanana); return(banana); }
public TMXIsoZorder() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-zorder"); AddChild(map, 0, kTagTileMap); CCSize s = map.ContentSize; CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height); m_tamara = new CCSprite(pathSister1); map.AddChild(m_tamara, map.Children.Count); m_tamara.AnchorPoint = CCPoint.AnchorMiddleBottom; m_tamara.RepeatForever(move, back); Schedule(repositionSprite); }
void AddNewSpriteWithCoords(CCPoint p) { CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)this[(int)kTags.kTagSpriteBatchNode]; int idx = (int)(CCRandom.NextDouble() * 1400 / 100); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121)); sprite.Position = (new CCPoint(p.X, p.Y)); BatchNode.AddChild(sprite); CCFiniteTimeAction action = null; var random = (float)CCRandom.NextDouble(); if (random < 0.20) { action = scaleBy; } else if (random < 0.40) { action = rotateBy; } else if (random < 0.60) { action = blink; } else if (random < 0.8) { action = tintBy; } else { action = fadeOut; } sprite.RepeatForever(action, action.Reverse()); }
CCSprite AddBanana() { var banana = new CCSprite("Banana"); double rnd = new Random().NextDouble(); double randomX = (rnd > 0) ? rnd * CCDirector.SharedDirector.WinSize.Width - banana.ContentSize.Width / 2 : banana.ContentSize.Width / 2; banana.Position = new CCPoint((float)randomX, CCDirector.SharedDirector.WinSize.Height - banana.ContentSize.Height / 2); AddChild(banana); var moveBanana = new CCMoveTo(5.0f, new CCPoint(banana.Position.X, 0)); banana.RunActions(moveBanana, moveBananaComplete); banana.RepeatForever(rotateBanana); return(banana); }
CCSprite ShootBanana() { if (bananaBatch.ChildrenCount < MAX_BANANAS_COUNT) { var banana = new CCSprite(bananasTexture); //var p = GetRandomPosition (banana.ContentSize); banana.Position = new CCPoint(monkey.Position.X, monkey.Position.Y + (banana.ContentSize.Height / 2)); banana.Scale = 0.5f; bananaBatch.AddChild(banana, 1); var moveBanana = new CCMoveTo(1 / _BananaSpeed, new CCPoint(banana.Position.X, VisibleBoundsWorldspace.Size.Height + banana.ContentSize.Height / 2)); banana.RunActions(moveBanana, moveBananaComplete); banana.RepeatForever(rotateBanana); CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/EnemyShoot.wav"); return(banana); } return(null); }
public void Update(double sliderNewValue) { hito.StopAllActions(); // 1回のCCMoveByアクションで進む距離を求める。0.15秒でスライダの値÷2進むことにする。 var distanceUnit = (float)sliderNewValue / 2; // 何回のCCMoveByアクションで画面の端から端まで行けるかを算出。 var actionCount = distance / distanceUnit; // Spriteの現在地情報から、終着点から最初の位置まで戻るアクションを入れる要素番号を取得する。 var index = Convert.ToInt32(Math.Floor((distance - (hito.ContentSize.Width / 2) - hito.PositionX) / distanceUnit)); // 端から端までCCMoveByで移動し、反対側の端に戻るシーケンスを組み立てる。 var moveAction = new CCMoveBy(0.15f, new CCPoint(distanceUnit, 0)); var backAction = new CCMoveTo(0, new CCPoint(firstPositionX, firstPositionY)); List <CCFiniteTimeAction> actionList = Enumerable.Repeat <CCFiniteTimeAction>(moveAction, (int)actionCount).ToList(); actionList.Insert(index, backAction); var sequence = new CCSequence(actionList.ToArray()); // 上で組み立てたシーケンスを永遠に繰り返す。 hito.RepeatForever(sequence); }
//CCWindowProjection preProjection; public CameraCenterTest() { CCSprite sprite; CCOrbitCamera orbit = new CCOrbitCamera(10, 1, 0, 0, 360, 0, 0);; // LEFT-TOP sprite = new CCSprite("Images/white-512x512") { Tag = 100 }; AddChild(sprite, 0); sprite.Color = CCColor3B.Red; sprite.TextureRectInPixels = new CCRect(0, 0, 120, 50); sprite.RepeatForever(orbit); // LEFT-BOTTOM sprite = new CCSprite("Images/white-512x512") { Tag = 101 }; AddChild(sprite, 0); sprite.Color = CCColor3B.Blue; sprite.TextureRectInPixels = new CCRect(0, 0, 120, 50); sprite.RepeatForever(orbit); // RIGHT-TOP sprite = new CCSprite("Images/white-512x512") { Tag = 102 }; AddChild(sprite, 0); sprite.Color = CCColor3B.Yellow; sprite.TextureRectInPixels = new CCRect(0, 0, 120, 50); sprite.RepeatForever(orbit); // RIGHT-BOTTOM sprite = new CCSprite("Images/white-512x512") { Tag = 103 }; AddChild(sprite, 0); sprite.Color = CCColor3B.Green; sprite.TextureRectInPixels = new CCRect(0, 0, 120, 50); sprite.RepeatForever(orbit); // CENTER sprite = new CCSprite("Images/white-512x512") { Tag = 104 }; AddChild(sprite, 0); sprite.Color = CCColor3B.White; sprite.TextureRectInPixels = new CCRect(0, 0, 120, 50); sprite.RepeatForever(orbit); }