public HighScoreLayer (int score): base() { currentScore = score; var batchnode = GetChildByTag ((int)Tags.SpriteManager) as CCSpriteBatchNode; var title = new CCSprite(batchnode.Texture,new CCRect(608,192,225,57)); title.Position=new CCPoint(160,240); batchnode.AddChild (title); var button1 = new CCMenuItemImage("Images/playAgainButton", "Images/playAgainButton", new Action<object>(delegate(object o) { CCDirector.SharedDirector.ReplaceScene(new CCTransitionFade(.5f, GameLayer.Scene, new CCColor3B(255,255,255))); })); var button2 = new CCMenuItemImage("Images/changePlayerButton", "Images/changePlayerButton", new Action<object>(delegate (object sender) { // do nothing })); var menu = new CCMenu(button1,button2); menu.Position=new CCPoint(160,58); menu.AlignItemsVerticallyWithPadding(9); AddChild (menu); }
public GameLayer() { TouchEnabled = true; localBananas = new List<CCSprite> (); localMonkey = new CCSprite ("MonkeyLocal"); localMonkey.PositionY = 0; localMonkey.PositionX = CCDirector.SharedDirector.WinSize.Width / 2; AddChild (localMonkey); remoteMonkey = new CCSprite ("MonkeyRemote"); remoteMonkey.PositionY = CCDirector.SharedDirector.WinSize.Height - remoteMonkey.ContentSizeInPixels.Height/2; remoteMonkey.PositionX = CCDirector.SharedDirector.WinSize.Width / 2; AddChild (remoteMonkey); if (!Context.isRoomCreator) { byte[] message = buildStartMessage (); sendWarpUpdate (message); beginLocalGame (); } Color = new CCColor3B (XNA.Color.ForestGreen); Opacity = 255; }
public SpriteBatchNodeReorderIssue767() { CCSize s = CCDirector.SharedDirector.WinSize; CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/ghosts.plist", "animations/ghosts"); CCNode aParent; CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2; // // SpriteBatchNode: 3 levels of children // aParent = new CCSpriteBatchNode("animations/ghosts"); AddChild(aParent, 0, (int) kTagSprite.kTagSprite1); // parent l1 = new CCSprite("father.gif"); l1.Position = (new CCPoint(s.Width / 2, s.Height / 2)); aParent.AddChild(l1, 0, (int) kTagSprite.kTagSprite2); CCSize l1Size = l1.ContentSize; // child left l2a = new CCSprite("sister1.gif"); l2a.Position = (new CCPoint(-25 + l1Size.Width / 2, 0 + l1Size.Height / 2)); l1.AddChild(l2a, -1, (int) kTags.kTagSpriteLeft); CCSize l2aSize = l2a.ContentSize; // child right l2b = new CCSprite("sister2.gif"); l2b.Position = (new CCPoint(+25 + l1Size.Width / 2, 0 + l1Size.Height / 2)); l1.AddChild(l2b, 1, (int) kTags.kTagSpriteRight); CCSize l2bSize = l2a.ContentSize; // child left bottom l3a1 = new CCSprite("child1.gif"); l3a1.Scale = (0.65f); l3a1.Position = (new CCPoint(0 + l2aSize.Width / 2, -50 + l2aSize.Height / 2)); l2a.AddChild(l3a1, -1); // child left top l3a2 = new CCSprite("child1.gif"); l3a2.Scale = (0.65f); l3a2.Position = (new CCPoint(0 + l2aSize.Width / 2, +50 + l2aSize.Height / 2)); l2a.AddChild(l3a2, 1); // child right bottom l3b1 = new CCSprite("child1.gif"); l3b1.Scale = (0.65f); l3b1.Position = (new CCPoint(0 + l2bSize.Width / 2, -50 + l2bSize.Height / 2)); l2b.AddChild(l3b1, -1); // child right top l3b2 = new CCSprite("child1.gif"); l3b2.Scale = (0.65f); l3b2.Position = (new CCPoint(0 + l2bSize.Width / 2, +50 + l2bSize.Height / 2)); l2b.AddChild(l3b2, 1); Schedule(reorderSprites, 1); }
public override void updateQuantityOfNodes() { CCSize s = CCDirector.SharedDirector.WinSize; // increase nodes if (currentQuantityOfNodes < quantityOfNodes) { StartTimer(); for (int i = 0; i < (quantityOfNodes - currentQuantityOfNodes); i++) { CCSprite sprite = new CCSprite(batchNode.Texture, new CCRect(0, 0, 32, 32)); batchNode.AddChild(sprite); sprite.Position = new CCPoint(CCRandom.Next() * s.Width, CCRandom.Next() * s.Height); sprite.Visible = false; } EndTimer("Current Quantity: add"); } // decrease nodes else if (currentQuantityOfNodes > quantityOfNodes) { StartTimer(); for (int i = 0; i < (currentQuantityOfNodes - quantityOfNodes); i++) { int index = currentQuantityOfNodes - i - 1; batchNode.RemoveChildAtIndex(index, true); } EndTimer("Current Quantity: add"); } currentQuantityOfNodes = quantityOfNodes; }
public SpriteBatchNodeAliased() { CCSpriteBatchNode batch = new CCSpriteBatchNode("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)(new CCSequence(scale, scale_back)); CCAction repeat = new CCRepeatForever (seq); CCAction repeat2 = (CCAction)(repeat.Copy()); sprite1.RunAction(repeat); sprite2.RunAction(repeat2); }
private void performanceRotationScale(CCSprite pSprite) { CCSize size = CCDirector.SharedDirector.WinSize; pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height)); pSprite.Rotation = CCRandom.Float_0_1() * 360; pSprite.Scale = CCRandom.Float_0_1() * 2; }
public Test5() { CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); sp2 = new CCSprite(TestResource.s_pPathSister2); sp1.Position = (new CCPoint(100, 160)); sp2.Position = (new CCPoint(380, 160)); CCRotateBy rot = new CCRotateBy (2, 360); var rot_back = rot.Reverse() as CCActionInterval; CCAction forever = new CCRepeatForever ((CCActionInterval)new CCSequence(rot, rot_back)); forever2 = (CCAction) (forever.Copy()); forever.Tag = (101); forever2.Tag = (102); AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1); AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); RemoveChild(sp2, true); AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); // Sprite 1 should run and run // Sprite 2 should stop sp1.RunAction(forever); sp2.RunAction(forever2); // Experiment with removing sp2 and re-adding it after cleanup to reproduce an error in child management // ScheduleOnce(Stage2OfTest, 2.0f); Schedule(addAndRemove, 2.0f); }
public ParallaxScrollTest() { CCSize screen = CCDirector.SharedDirector.WinSize; parallax = new CCParallaxScrollNode(); CCSprite land1 = new CCSprite("Images/land_green"); CCSprite land2 = new CCSprite("Images/land_green"); parallax.AddInfiniteScrollXWithZ(0, new CCPoint(0.5f, 0.2f), CCPoint.Zero, new CCSprite[] { land1, land2 }); CCSprite land3 = new CCSprite("Images/land_grey"); CCSprite land4 = new CCSprite("Images/land_grey"); parallax.AddInfiniteScrollXWithZ(-2, new CCPoint(0.05f, 0.2f), new CCPoint(0f, 60f), new CCSprite[] { land3, land4 }); CCSprite clouds1 = new CCSprite("Images/clouds"); CCSprite clouds2 = new CCSprite("Images/clouds"); parallax.AddInfiniteScrollXWithZ(1, new CCPoint(0.1f, 0.1f), new CCPoint(0f, screen.Height - clouds1.ContentSize.Height), new CCSprite[] { clouds1, clouds2 }); for (int i = 0; i < 10; i++) { CCSprite mountain = new CCSprite("Images/mountain_grey"); CCPoint pos = new CCPoint(CCMacros.CCRandomBetween0And1() * land1.ContentSize.Width * 2f, (0.1f + 0.24f * CCMacros.CCRandomBetween0And1()) * screen.Height); float speedMountainX = 0.15f + CCMacros.CCRandomBetween0And1() * 0.1f; parallax.AddChild(mountain, -1, new CCPoint(speedMountainX, .015f), pos, new CCPoint(land1.ContentSize.Width * 2f, 0)); mountain.Scale = 0.6f + CCMacros.CCRandomBetween0And1() * 0.4f; } CCSprite sky = new CCSprite("Images/sky_evening"); sky.AnchorPoint = CCPoint.AnchorLowerLeft; AddChild(parallax); AddChild(sky, -1); }
public override bool Init() { InitWithColor(new CCColor4B(0, 0, 255, 255)); var item0 = new CCMenuItemFont("(3) Touch to pushScene (self)", item0Clicked); var item1 = new CCMenuItemFont("(3) Touch to popScene", item1Clicked); var item2 = new CCMenuItemFont("(3) Touch to popToRootScene", item2Clicked); var item3 = new CCMenuItemFont("(3) Touch to popToSceneStackLevel(2)", item3Clicked); CCMenu menu = new CCMenu(item0, item1, item2, item3); menu.AlignItemsVertically(); AddChild(menu); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sprite = new CCSprite(s_pPathGrossini); AddChild(sprite); sprite.Position = new CCPoint(s.Width /2, 40); CCActionInterval rotate = new CCRotateBy (2, 360); CCAction repeat = new CCRepeatForever (rotate); sprite.RunAction(repeat); Schedule(testDealloc); return true; }
public virtual CCTableViewCell TableCellAtIndex(CCTableView table, int idx) { string str = idx.ToString(); var cell = table.DequeueCell(); if (cell == null) { cell = new CustomTableViewCell(); var sprite = new CCSprite("Images/Icon"); sprite.AnchorPoint = CCPoint.Zero; sprite.Position = new CCPoint(0, 0); cell.AddChild(sprite); var label = new CCLabelTTF(str, "Helvetica", 20.0f); label.Position = CCPoint.Zero; label.AnchorPoint = CCPoint.Zero; label.Tag = 123; cell.AddChild(label); } else { var label = (CCLabelTTF)cell.GetChildByTag(123); label.Label = (str); } return cell; }
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)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
public static CCMenuItem CreateScaledMenuItemLabel(CCSize buttonSize, int labelPadding, float strokeSize, CCColor3B textColor, CCColor3B strokeColor, CCColor3B backColor, string labelText, Action action) { var menuItem = action != null ? new CCMenuItem(o => action()) : new CCMenuItem(); var labelSize = new CCSize(buttonSize.Width - labelPadding, buttonSize.Height - labelPadding); // Add background var blockSprite = new CCSprite("images/Block_Back"); blockSprite.ScaleTo(buttonSize); blockSprite.Color = backColor; menuItem.AddChild(blockSprite); menuItem.ContentSize = buttonSize; // Add label var labelTtf = new CCLabelTTF(labelText, "arial-24", 10); labelTtf.Color = textColor; // Add Stroke to label // if (strokeSize > 0) labelTtf.AddStroke(strokeSize, strokeColor); if (labelTtf.ContentSize.Width > labelSize.Width) { labelTtf.ScaleTo(labelSize); } menuItem.AddChild(labelTtf); return menuItem; }
public override void OnEnter() { // // This test MUST be done in 'onEnter' and not on 'init' // otherwise the paused action will be resumed at 'onEnter' time // base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF l = new CCLabelTTF("After 5 seconds grossini should move", "arial", 16); AddChild(l); l.Position = (new CCPoint(s.Width / 2, 245)); // // Also, this test MUST be done, after [super onEnter] // CCSprite grossini = new CCSprite(s_pPathGrossini); AddChild(grossini, 0, kTagGrossini); grossini.Position = (new CCPoint(200, 200)); CCAction action = new CCMoveBy (1, new CCPoint(150, 0)); CCDirector.SharedDirector.ActionManager.AddAction(action, grossini, true); Schedule(unpause, 3); }
public Test6() { CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2); CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2); sp1.Position = (new CCPoint(100, 160)); sp2.Position = (new CCPoint(380, 160)); CCActionInterval rot = new CCRotateBy (2, 360); var rot_back = rot.Reverse() as CCActionInterval; CCAction forever1 = new CCRepeatForever ((CCActionInterval)new CCSequence(rot, rot_back)); var forever11 = (CCAction) (forever1.Copy()); var forever2 = (CCAction) (forever1.Copy()); var forever21 = (CCAction) (forever1.Copy()); AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1); sp1.AddChild(sp11); AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); sp2.AddChild(sp21); sp1.RunAction(forever1); sp11.RunAction(forever11); sp2.RunAction(forever2); sp21.RunAction(forever21); Schedule(addAndRemove, 2.0f); }
public StressTest2() { CCSize s = CCDirector.SharedDirector.WinSize; CCLayer sublayer = new CCLayer(); CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); sp1.Position = (new CCPoint(80, s.Height / 2)); CCActionInterval move = new CCMoveBy (3, new CCPoint(350, 0)); CCActionInterval move_ease_inout3 = new CCEaseInOut((CCActionInterval) (move.Copy()), 2.0f); var move_ease_inout_back3 = (CCActionInterval) move_ease_inout3.Reverse(); CCFiniteTimeAction seq3 = new CCSequence(move_ease_inout3, move_ease_inout_back3); sp1.RunAction(new CCRepeatForever ((CCActionInterval) seq3)); sublayer.AddChild(sp1, 1); CCParticleFire fire = new CCParticleFire(); fire.Texture = (CCTextureCache.SharedTextureCache.AddImage("Images/fire")); fire.Position = (new CCPoint(80, s.Height / 2 - 50)); var copy_seq3 = (CCActionInterval) (seq3.Copy()); fire.RunAction(new CCRepeatForever (copy_seq3)); sublayer.AddChild(fire, 2); Schedule((shouldNotLeak), 6.0f); AddChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1); }
public NodeToWorld() { // // This code tests that nodeToParent works OK: // - It tests different anchor Points // - It tests different children anchor points CCSprite back = new CCSprite(TestResource.s_back3); AddChild(back, -10); back.AnchorPoint = (new CCPoint(0, 0)); CCSize backSize = back.ContentSize; CCMenuItem item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect); CCMenu menu = new CCMenu(item); menu.AlignItemsVertically(); menu.Position = (new CCPoint(backSize.Width / 2, backSize.Height / 2)); back.AddChild(menu); CCActionInterval rot = new CCRotateBy (5, 360); CCAction fe = new CCRepeatForever (rot); item.RunAction(fe); CCActionInterval move = new CCMoveBy (3, new CCPoint(200, 0)); var move_back = (CCActionInterval) move.Reverse(); CCFiniteTimeAction seq = new CCSequence(move, move_back); CCAction fe2 = new CCRepeatForever ((CCActionInterval) seq); back.RunAction(fe2); }
public RenderTextureCompositeTest() { var winSize = CCDirector.SharedDirector.WinSize; var characterSpriteFactory = new CharacterSpriteFactory(); _testSprite = new CCSprite(@"Images\grossini_dance_01"); _testSprite2 = new CCSprite(@"Images\grossini_dance_02"); _swingAnimate = characterSpriteFactory.CreateAnimateAction(); _thrustAnimate = characterSpriteFactory.CreateAnimateAction(); _dodgeAnimate = characterSpriteFactory.CreateAnimateAction(); _collapseAnimate = characterSpriteFactory.CreateAnimateAction(); _swingAnimate2 = characterSpriteFactory.CreateAnimateAction(); _thrustAnimate2 = characterSpriteFactory.CreateAnimateAction(); _dodgeAnimate2 = characterSpriteFactory.CreateAnimateAction(); _collapseAnimate2 = characterSpriteFactory.CreateAnimateAction(); _testSprite.Position = new CCPoint(winSize.Width / 2 -200, winSize.Height / 2 + 100); AddChild(_testSprite); _testSprite2.Position = new CCPoint(winSize.Width / 2 + 200, winSize.Height / 2 + 100); _testSprite2.FlipX = true; AddChild(_testSprite2); AnimationLoop(); AnimationLoop2(); }
/** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ protected virtual bool InitWithMaskSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel, CCLabelTTF offLabel) { if (base.Init()) { Debug.Assert(maskSprite != null, "Mask must not be nil."); Debug.Assert(onSprite != null, "onSprite must not be nil."); Debug.Assert(offSprite != null, "offSprite must not be nil."); Debug.Assert(thumbSprite != null, "thumbSprite must not be nil."); TouchEnabled = true; _on = true; _switchSprite = new CCControlSwitchSprite(); _switchSprite.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); _switchSprite.Position = new CCPoint(_switchSprite.ContentSize.Width / 2, _switchSprite.ContentSize.Height / 2); AddChild(_switchSprite); IgnoreAnchorPointForPosition = false; AnchorPoint = new CCPoint(0.5f, 0.5f); ContentSize = _switchSprite.ContentSize; return true; } return false; }
public IntroLayer() { CCSize windowSize = CCDirector.SharedDirector.WinSize; CCSprite tmp = new CCSprite("goblins"); tmp.SetPosition(windowSize.Width / 2, windowSize.Height / 2); AddChild(tmp); String name = @"Content/goblins"; skeletonNode = new CCSkeletonAnimation(name + ".json", name + ".atlas", 1.0f); if (name == "goblins") skeletonNode.setSkin("goblin"); skeletonNode.NodeToWorldTransform(); skeletonNode.setSlotsToSetupPose(); skeletonNode.updateWorldTransform(); skeletonNode.AddAnimation(0, "walk", true, 4); skeletonNode.SetAnimation(0, "walk", true); skeletonNode.Start += Start; skeletonNode.End += End; skeletonNode.Complete += Complete; skeletonNode.Event += Event; skeletonNode.findSlot("head"); skeletonNode.SetPosition(windowSize.Width / 2, windowSize.Height / 2); AddChild(skeletonNode); }
/** Creates and returns a new ControlStepper. */ public CCControlStepper MakeControlStepper() { var minusSprite = new CCSprite("extensions/stepper-minus.png"); var plusSprite = new CCSprite("extensions/stepper-plus.png"); return new CCControlStepper(minusSprite, plusSprite); }
public override void OnEnter() { base.OnEnter(); m_grossini = new CCSprite(TestResource.s_pPathGrossini); m_tamara = new CCSprite(TestResource.s_pPathSister1); m_kathia = new CCSprite(TestResource.s_pPathSister2); AddChild(m_grossini, 3); AddChild(m_kathia, 2); AddChild(m_tamara, 1); var s = CCDirector.SharedDirector.WinSize; m_grossini.Position = new CCPoint(60, 50); m_kathia.Position = new CCPoint(60, 150); m_tamara.Position = new CCPoint(60, 250); var label = new CCLabelTTF(title(), "arial", 32); AddChild(label); label.Position = new CCPoint(s.Width / 2, s.Height - 50); var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); var menu = new CCMenu(item1, item2, item3); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); AddChild(menu, 1); }
public SpriteZOrder() { m_dir = 1; CCSize s = CCDirector.SharedDirector.WinSize; float step = s.Width / 11; for (int i = 0; i < 5; i++) { CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2)); AddChild(sprite, i); } for (int i = 5; i < 10; i++) { CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121)); sprite.Position = new CCPoint((i + 1) * step, s.Height / 2); AddChild(sprite, 14 - i); } CCSprite sprite1 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 0, 85, 121)); AddChild(sprite1, -1, (int)kTagSprite.kTagSprite1); sprite1.Position = (new CCPoint(s.Width / 2, s.Height / 2 - 20)); sprite1.Scale = 6; sprite1.Color = new CCColor3B(Color.Red); Schedule(reorderSprite, 1); }
public CameraZoomTest() { CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sprite; CCCamera cam; // LEFT sprite = new CCSprite(TestResource.s_pPathGrossini); AddChild(sprite, 0); sprite.Position = (new CCPoint(s.Width / 4 * 1, s.Height / 2)); cam = sprite.Camera; cam.SetEyeXyz(0, 0, 415 / 2); cam.SetCenterXyz(0, 0, 0); // CENTER sprite = new CCSprite(TestResource.s_pPathGrossini); AddChild(sprite, 0, 40); sprite.Position = (new CCPoint(s.Width / 4 * 2, s.Height / 2)); // RIGHT sprite = new CCSprite(TestResource.s_pPathGrossini); AddChild(sprite, 0, 20); sprite.Position = (new CCPoint(s.Width / 4 * 3, s.Height / 2)); m_z = 0; ScheduleUpdate(); }
public override void OnEnter() { base.OnEnter(); CCActionInterval effect = (CCSequence.FromActions(new CCDelayTime (2.0f), new CCShaky3D(16, false, new CCGridSize(5, 5), 5.0f))); // cleanup CCNode bg = GetChildByTag(EffectAdvanceScene.kTagBackground); RemoveChild(bg, true); // background CCLayerColor layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255)); AddChild(layer, -10); CCSprite sprite = new CCSprite("Images/grossini"); sprite.Position = new CCPoint(50, 80); layer.AddChild(sprite, 10); // foreground CCLayerColor layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255)); CCSprite fog = new CCSprite("Images/Fog"); var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA}; fog.BlendFunc = bf; layer2.AddChild(fog, 1); AddChild(layer2, 1); layer2.RunAction(new CCRepeatForever (effect)); }
public void addNewSpriteWithCoords(CCPoint p) { CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((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)); BatchNode.AddChild(sprite); sprite.Position = (new CCPoint(p.X, p.Y)); CCActionInterval action = null; float random = (float)CCRandom.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)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
public SpriteBatchNodeZOrder() { m_dir = 1; // small capacity. Testing resizing. // Don't use capacity=1 in your real game. It is expensive to resize the capacity CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSize s = CCDirector.SharedDirector.WinSize; float step = s.Width / 11; for (int i = 0; i < 5; i++) { CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121)); sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2)); batch.AddChild(sprite, i); } for (int i = 5; i < 10; i++) { CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 0, 85, 121)); sprite.Position = new CCPoint((i + 1) * step, s.Height / 2); batch.AddChild(sprite, 14 - i); } CCSprite sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 0, 85, 121)); batch.AddChild(sprite1, -1, (int)kTagSprite.kTagSprite1); sprite1.Position = (new CCPoint(s.Width / 2, s.Height / 2 - 20)); sprite1.Scale = 6; sprite1.Color = new CCColor3B(Color.Red); Schedule(reorderSprite, 1); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("zwoptex/grossini.plist"); CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("zwoptex/grossini-generic.plist"); CCLayerColor layer1 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 85, 121); layer1.Position = new CCPoint(s.Width / 2 - 80 - (85.0f * 0.5f), s.Height / 2 - (121.0f * 0.5f)); AddChild(layer1); sprite1 = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName("grossini_dance_01.png")); sprite1.Position = (new CCPoint(s.Width / 2 - 80, s.Height / 2)); AddChild(sprite1); sprite1.FlipX = false; sprite1.FlipY = false; CCLayerColor layer2 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 85, 121); layer2.Position = new CCPoint(s.Width / 2 + 80 - (85.0f * 0.5f), s.Height / 2 - (121.0f * 0.5f)); AddChild(layer2); sprite2 = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName("grossini_dance_generic_01.png")); sprite2.Position = (new CCPoint(s.Width / 2 + 80, s.Height / 2)); AddChild(sprite2); sprite2.FlipX = false; sprite2.FlipY = false; Schedule(startIn05Secs, 1.0f); counter = 0; }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = CCDirector.SharedDirector.WinSize; // sun CCParticleSystem sun = new CCParticleSun(); sun.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); sun.Position = (new CCPoint(s.Width - 32, s.Height - 32)); sun.TotalParticles = 130; sun.Life = (0.6f); AddChild(sun); // timers m_label0 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label1 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label2 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label3 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label4 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); ScheduleUpdate(); Schedule(step1); Schedule(step2, 0); Schedule(step3, 1.0f); Schedule(step4, 2.0f); m_label0.Position = new CCPoint(s.Width * 1 / 6, s.Height / 2); m_label1.Position = new CCPoint(s.Width * 2 / 6, s.Height / 2); m_label2.Position = new CCPoint(s.Width * 3 / 6, s.Height / 2); m_label3.Position = new CCPoint(s.Width * 4 / 6, s.Height / 2); m_label4.Position = new CCPoint(s.Width * 5 / 6, s.Height / 2); AddChild(m_label0); AddChild(m_label1); AddChild(m_label2); AddChild(m_label3); AddChild(m_label4); // Sprite CCSprite sprite = new CCSprite(s_pPathGrossini); sprite.Position = new CCPoint(40, 50); CCJumpBy jump = new CCJumpBy (3, new CCPoint(s.Width - 80, 0), 50, 4); AddChild(sprite); sprite.RunAction(new CCRepeatForever ( (CCActionInterval) (new CCSequence(jump, jump.Reverse()))) ); // pause button CCMenuItem item1 = new CCMenuItemFont("Pause", onPause); CCMenu menu = new CCMenu(item1); menu.Position = new CCPoint(s.Width / 2, s.Height - 50); AddChild(menu); }
public RenderTextureZbuffer() { //this->setIsTouchEnabled(true); TouchEnabled = true; CCSize size = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF("vertexZ = 50", "Marker Felt", 32); label.Position = new CCPoint(size.Width / 2, size.Height * 0.25f); AddChild(label); CCLabelTTF label2 = new CCLabelTTF("vertexZ = 0", "Marker Felt", 32); label2.Position = new CCPoint(size.Width / 2, size.Height * 0.5f); AddChild(label2); CCLabelTTF label3 = new CCLabelTTF("vertexZ = -50", "Marker Felt", 32); label3.Position = new CCPoint(size.Width / 2, size.Height * 0.75f); AddChild(label3); label.VertexZ = 50; label2.VertexZ = 0; label3.VertexZ = -50; CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("Images/bugs/circle.plist"); mgr = new CCSpriteBatchNode("Images/bugs/circle", 9); AddChild(mgr); sp1 = new CCSprite("Images/bugs/circle"); sp2 = new CCSprite("Images/bugs/circle"); sp3 = new CCSprite("Images/bugs/circle"); sp4 = new CCSprite("Images/bugs/circle"); sp5 = new CCSprite("Images/bugs/circle"); sp6 = new CCSprite("Images/bugs/circle"); sp7 = new CCSprite("Images/bugs/circle"); sp8 = new CCSprite("Images/bugs/circle"); sp9 = new CCSprite("Images/bugs/circle"); mgr.AddChild(sp1, 9); mgr.AddChild(sp2, 8); mgr.AddChild(sp3, 7); mgr.AddChild(sp4, 6); mgr.AddChild(sp5, 5); mgr.AddChild(sp6, 4); mgr.AddChild(sp7, 3); mgr.AddChild(sp8, 2); mgr.AddChild(sp9, 1); sp1.VertexZ = 400; sp2.VertexZ = 300; sp3.VertexZ = 200; sp4.VertexZ = 100; sp5.VertexZ = 0; sp6.VertexZ = -100; sp7.VertexZ = -200; sp8.VertexZ = -300; sp9.VertexZ = -400; sp9.Scale = 2; sp9.Color = CCTypes.CCYellow; }
public CCControlPotentiometer() { _thumbSprite = null; _progressTimer = null; _value = 0.0f; _minimumValue = 0.0f; _maximumValue = 0.0f; }
/** * Creates a slider with a given background sprite and a progress bar and a * thumb item. * * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ public CCControlSlider(CCSprite backgroundSprite, CCSprite progressSprite, CCSprite thumbSprite) { InitWithSprites(backgroundSprite, progressSprite, thumbSprite); }
public void AddSprite(CCSprite sprite) { CCSpriteFrame f = new CCSpriteFrame(sprite.Texture, new CCRect(0, 0, sprite.ContentSize.Width, sprite.ContentSize.Height)); AddSpriteFrame(f); }
public void CreateFontChars() { int nextFontPositionX = 0; int nextFontPositionY = 0; //unsigned short prev = -1; int kerningAmount = 0; CCSize tmpSize = CCSize.Zero; int longestLine = 0; int totalHeight = 0; int quantityOfLines = 1; int stringLen = m_sString.Length; if (stringLen == 0) { return; } for (int i = 0; i < stringLen - 1; ++i) { if (m_sString[i] == '\n') { quantityOfLines++; } } totalHeight = m_pConfiguration.m_nCommonHeight * quantityOfLines; nextFontPositionY = 0 - (m_pConfiguration.m_nCommonHeight - m_pConfiguration.m_nCommonHeight * quantityOfLines); for (int i = 0; i < stringLen; i++) { char c = m_sString[i]; if (c == '\n') { nextFontPositionX = 0; nextFontPositionY -= m_pConfiguration.m_nCommonHeight; continue; } // unichar is a short, and an int is needed on HASH_FIND_INT CCBMFontConfiguration.ccBMFontDef fontDef = m_pConfiguration.m_pFontDefDictionary[c]; CCRect rect = fontDef.rect; rect = CCMacros.CCRectanglePixelsToPoints(rect); rect.Origin.X += m_tImageOffset.X; rect.Origin.Y += m_tImageOffset.Y; CCSprite fontChar; fontChar = (CCSprite)(GetChildByTag(i)); if (fontChar == null) { fontChar = new CCSprite(m_pobTextureAtlas.Texture, rect); AddChild(fontChar, 0, i); } else { // reusing fonts fontChar.SetTextureRect(rect, false, rect.Size); // restore to default in case they were modified fontChar.Visible = true; fontChar.Opacity = 255; } // See issue 1343. cast( signed short + unsigned integer ) == unsigned integer (sign is lost!) int yOffset = m_pConfiguration.m_nCommonHeight - fontDef.yOffset; var fontPos = new CCPoint((float)nextFontPositionX + fontDef.xOffset + fontDef.rect.Size.Width * 0.5f + kerningAmount, (float)nextFontPositionY + yOffset - rect.Size.Height * 0.5f * CCMacros.CCContentScaleFactor()); fontChar.Position = CCMacros.CCPointPixelsToPoints(fontPos); // update kerning nextFontPositionX += fontDef.xAdvance + kerningAmount; //prev = c; // Apply label properties fontChar.IsOpacityModifyRGB = m_bIsOpacityModifyRGB; // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on fontChar.Color = m_tColor; // only apply opacity if it is different than 255 ) // to prevent modifying the color too (issue #610) if (m_cOpacity != 255) { fontChar.Opacity = m_cOpacity; } if (longestLine < nextFontPositionX) { longestLine = nextFontPositionX; } } tmpSize.Width = longestLine; tmpSize.Height = totalHeight; ContentSize = CCMacros.CCSizePixelsToPoints(tmpSize); }
public void SetSelectedSpriteFrame(CCSpriteFrame frame) { SelectedImage = new CCSprite(frame); }
/** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ protected virtual bool InitWithMaskSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel, CCLabelTTF offLabel) { if (base.Init()) { Debug.Assert(maskSprite != null, "Mask must not be nil."); Debug.Assert(onSprite != null, "onSprite must not be nil."); Debug.Assert(offSprite != null, "offSprite must not be nil."); Debug.Assert(thumbSprite != null, "thumbSprite must not be nil."); TouchEnabled = true; _on = true; _switchSprite = new CCControlSwitchSprite(); _switchSprite.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); _switchSprite.Position = new CCPoint(_switchSprite.ContentSize.Width / 2, _switchSprite.ContentSize.Height / 2); AddChild(_switchSprite); IgnoreAnchorPointForPosition = false; AnchorPoint = new CCPoint(0.5f, 0.5f); ContentSize = _switchSprite.ContentSize; return(true); } return(false); }
/** * Initializes a slider with a background sprite, a progress bar and a thumb * item. * * @param backgroundSprite CCSprite, that is used as a background. * @param progressSprite CCSprite, that is used as a progress bar. * @param thumbItem CCMenuItem, that is used as a thumb. */ public virtual bool InitWithSprites(CCSprite backgroundSprite, CCSprite progressSprite, CCSprite thumbSprite) { if (base.Init()) { Debug.Assert(backgroundSprite != null, "Background sprite must be not nil"); Debug.Assert(progressSprite != null, "Progress sprite must be not nil"); Debug.Assert(thumbSprite != null, "Thumb sprite must be not nil"); IgnoreAnchorPointForPosition = false; TouchEnabled = true; BackgroundSprite = backgroundSprite; ProgressSprite = progressSprite; ThumbSprite = thumbSprite; // Defines the content size CCRect maxRect = CCControlUtils.CCRectUnion(backgroundSprite.BoundingBox, thumbSprite.BoundingBox); ContentSize = new CCSize(maxRect.Size.Width, maxRect.Size.Height); //setContentSize(CCSizeMake(backgroundSprite->getContentSize().width, thumbItem->getContentSize().height)); // Add the slider background _backgroundSprite.AnchorPoint = new CCPoint(0.5f, 0.5f); _backgroundSprite.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2); AddChild(_backgroundSprite); // Add the progress bar _progressSprite.AnchorPoint = new CCPoint(0.0f, 0.5f); _progressSprite.Position = new CCPoint(0.0f, ContentSize.Height / 2); AddChild(_progressSprite); // Add the slider thumb _thumbSprite.Position = new CCPoint(0, ContentSize.Height / 2); AddChild(_thumbSprite); // Init default values _minimumValue = 0.0f; _maximumValue = 1.0f; Value = _minimumValue; return(true); } return(false); }
protected virtual bool InitWithMaskSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite) { return(InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, null, null)); }
/** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ public CCControlSwitch(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite) { InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, null, null); }
/** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ public CCControlSwitch(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel, CCLabelTTF offLabel) { InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); }
protected virtual bool InitWithString(string theString, string fntFile, CCSize dimentions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCPoint imageOffset, CCTexture2D texture) { Debug.Assert(m_pConfiguration == null, "re-init is no longer supported"); Debug.Assert((theString == null && fntFile == null) || (theString != null && fntFile != null), "Invalid params for CCLabelBMFont"); if (!String.IsNullOrEmpty(fntFile)) { CCBMFontConfiguration newConf = FNTConfigLoadFile(fntFile); if (newConf == null) { CCLog.Log("CCLabelBMFont: Impossible to create font. Please check file: '{0}'", fntFile); return(false); } m_pConfiguration = newConf; m_sFntFile = fntFile; if (texture == null) { try { texture = CCTextureCache.SharedTextureCache.AddImage(m_pConfiguration.AtlasName); } catch (Exception) { // Try the 'images' ref location just in case. try { texture = CCTextureCache.SharedTextureCache.AddImage(System.IO.Path.Combine("images", m_pConfiguration .AtlasName)); } catch (Exception) { // Lastly, try <font_path>/images/<font_name> string dir = System.IO.Path.GetDirectoryName(m_pConfiguration.AtlasName); string fname = System.IO.Path.GetFileName(m_pConfiguration.AtlasName); string newName = System.IO.Path.Combine(System.IO.Path.Combine(dir, "images"), fname); texture = CCTextureCache.SharedTextureCache.AddImage(newName); } } } } else { texture = new CCTexture2D(); } if (String.IsNullOrEmpty(theString)) { theString = String.Empty; } if (base.InitWithTexture(texture, theString.Length)) { m_tDimensions = dimentions; m_pHAlignment = hAlignment; m_pVAlignment = vAlignment; m_cDisplayedOpacity = m_cRealOpacity = 255; m_tDisplayedColor = m_tRealColor = CCTypes.CCWhite; m_bCascadeOpacityEnabled = true; m_bCascadeColorEnabled = true; m_obContentSize = CCSize.Zero; m_bIsOpacityModifyRGB = m_pobTextureAtlas.Texture.HasPremultipliedAlpha; AnchorPoint = new CCPoint(0.5f, 0.5f); m_tImageOffset = imageOffset; m_pReusedChar = new CCSprite(); m_pReusedChar.InitWithTexture(m_pobTextureAtlas.Texture, CCRect.Zero, false); m_pReusedChar.BatchNode = this; SetString(theString, true); return(true); } return(false); }
public void CreateFontChars() { int nextFontPositionX = 0; int nextFontPositionY = 0; char prev = (char)255; int kerningAmount = 0; CCSize tmpSize = CCSize.Zero; int longestLine = 0; int totalHeight = 0; int quantityOfLines = 1; if (String.IsNullOrEmpty(m_sString)) { return; } int stringLen = m_sString.Length; var charSet = m_pConfiguration.CharacterSet; if (charSet.Count == 0) { throw (new InvalidOperationException( "Can not compute the size of the font because the character set is empty.")); } for (int i = 0; i < stringLen - 1; ++i) { if (m_sString[i] == '\n') { quantityOfLines++; } } totalHeight = m_pConfiguration.m_nCommonHeight * quantityOfLines; nextFontPositionY = 0 - (m_pConfiguration.m_nCommonHeight - m_pConfiguration.m_nCommonHeight * quantityOfLines); CCBMFontConfiguration.CCBMFontDef fontDef = null; CCRect rect; for (int i = 0; i < stringLen; i++) { char c = m_sString[i]; if (c == '\n') { nextFontPositionX = 0; nextFontPositionY -= m_pConfiguration.m_nCommonHeight; continue; } if (charSet.IndexOf(c) == -1) { CCLog.Log("Cocos2D.CCLabelBMFont: Attempted to use character not defined in this bitmap: {0}", (int)c); continue; } kerningAmount = this.KerningAmountForFirst(prev, c); // unichar is a short, and an int is needed on HASH_FIND_INT if (!m_pConfiguration.m_pFontDefDictionary.TryGetValue(c, out fontDef)) { CCLog.Log("cocos2d::CCLabelBMFont: characer not found {0}", (int)c); continue; } rect = fontDef.rect; rect = CCMacros.CCRectanglePixelsToPoints(rect); rect.Origin.X += m_tImageOffset.X; rect.Origin.Y += m_tImageOffset.Y; CCSprite fontChar; //bool hasSprite = true; fontChar = (CCSprite)(GetChildByTag(i)); if (fontChar != null) { // Reusing previous Sprite fontChar.Visible = true; } else { // New Sprite ? Set correct color, opacity, etc... //if( false ) //{ // /* WIP: Doesn't support many features yet. // But this code is super fast. It doesn't create any sprite. // Ideal for big labels. // */ // fontChar = m_pReusedChar; // fontChar.BatchNode = null; // hasSprite = false; //} //else { fontChar = new CCSprite(); fontChar.InitWithTexture(m_pobTextureAtlas.Texture, rect); AddChild(fontChar, i, i); } // Apply label properties fontChar.IsOpacityModifyRGB = m_bIsOpacityModifyRGB; // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on fontChar.UpdateDisplayedColor(m_tDisplayedColor); fontChar.UpdateDisplayedOpacity(m_cDisplayedOpacity); } // updating previous sprite fontChar.SetTextureRect(rect, false, rect.Size); // See issue 1343. cast( signed short + unsigned integer ) == unsigned integer (sign is lost!) int yOffset = m_pConfiguration.m_nCommonHeight - fontDef.yOffset; var fontPos = new CCPoint( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.Size.Width * 0.5f + kerningAmount, (float)nextFontPositionY + yOffset - rect.Size.Height * 0.5f * CCMacros.CCContentScaleFactor()); fontChar.Position = CCMacros.CCPointPixelsToPoints(fontPos); // update kerning nextFontPositionX += fontDef.xAdvance + kerningAmount; prev = c; if (longestLine < nextFontPositionX) { longestLine = nextFontPositionX; } //if (! hasSprite) //{ // UpdateQuadFromSprite(fontChar, i); //} } // If the last character processed has an xAdvance which is less that the width of the characters image, then we need // to adjust the width of the string to take this into account, or the character will overlap the end of the bounding // box if (fontDef.xAdvance < fontDef.rect.Size.Width) { tmpSize.Width = longestLine + fontDef.rect.Size.Width - fontDef.xAdvance; } else { tmpSize.Width = longestLine; } tmpSize.Height = totalHeight; tmpSize = new CCSize( m_tDimensions.Width > 0 ? m_tDimensions.Width : tmpSize.Width, m_tDimensions.Height > 0 ? m_tDimensions.Height : tmpSize.Height ); ContentSize = CCMacros.CCSizePixelsToPoints(tmpSize); }
public virtual bool CollidesWith(CCSprite other, out CCPoint hitPoint) { // Default behavior uses per-pixel collision detection return(CollidesWith(other, out hitPoint, true)); }
public CCControlStepper(CCSprite minusSprite, CCSprite plusSprite) { InitWithMinusSpriteAndPlusSprite(minusSprite, plusSprite); }
/// <summary> /// Tests the collision mask for the two sprites and returns true if there is a collision. The hit point of the /// collision is returned. /// </summary> /// <param name="a">Sprite A</param> /// <param name="b">Sprite B</param> /// <param name="hitPoint">The place, in real space, where they collide</param> /// <returns>True upon collision and false if not.</returns> static bool MaskCollision(CCSprite a, CCSprite b, out CCPoint hitPoint) { long lStart = DateTime.Now.Ticks; try { byte[] maskA = a.CollisionMask; // bitfield mask of sprite A byte[] maskB = b.CollisionMask; // bitfield mask of sprite B int aWidth = (int)a.Texture.ContentSize.Width; // bitwise stride int bWidth = (int)b.Texture.ContentSize.Width; // bitwise stride int aHeight = (int)a.Texture.ContentSize.Height; int bHeight = (int)b.Texture.ContentSize.Height; // Calculate the intersecting rectangle int x1 = Math.Max(a.Bounds.X, b.Bounds.X); int x2 = Math.Min(a.Bounds.X + a.Bounds.Width, b.Bounds.X + b.Bounds.Width); int y1 = Math.Max(a.Bounds.Y, b.Bounds.Y); int y2 = Math.Min(a.Bounds.Y + a.Bounds.Height, b.Bounds.Y + b.Bounds.Height); // Next extract the bitfields for the intersection rectangles for (int y = y1; y < y2; ++y) { for (int x = x1; x < x2; x++) { // Coordinates in the respective sprites // Invert the Y because screen coords are opposite of mask coordinates! int xA = x - a.Bounds.X; int yA = aHeight - (y - a.Bounds.Y); if (yA < 0) { yA = 0; } else if (yA >= aHeight) { yA = aHeight - 1; } int xB = x - b.Bounds.X; int yB = bHeight - (y - b.Bounds.Y); if (yB < 0) { yB = 0; } else if (yB >= bHeight) { yB = bHeight - 1; } // Get the color from each texture byte ca = maskA[xA + yA * aWidth]; byte cb = maskB[xB + yB * bWidth]; #if DEBUG if (a.DebugCollision && b.DebugCollision) { CCLog.Log("Collision test[{0},{1}] = A{2} == B{3} {4}", x, y, ca, cb, (ca == cb && ca > 0) ? "BOOM" : ""); } #endif if (ca > 0 && cb > 0) // If both colors are not transparent (the alpha channel is not 0), then there is a collision { // Find the hit point, where on the sprite in real space the collision occurs. hitPoint = new CCPoint(a.Position.X - a.AnchorPoint.X * a.ContentSizeInPixels.Width + x, a.Position.Y - a.AnchorPoint.Y * a.ContentSizeInPixels.Height + y); return(true); } } } hitPoint.X = 0; hitPoint.Y = 0; return(false); } finally { long diff = DateTime.Now.Ticks - lStart; CCLog.Log("Bitwise Collision took {0:N2} ms", new TimeSpan(diff).TotalMilliseconds); } }
public bool UpdateWithBatchNode(CCSpriteBatchNode batchnode, CCRect rect, bool rotated, CCRect capInsets) { byte opacity = m_cOpacity; CCColor3B color = m_tColor; // Release old sprites RemoveAllChildrenWithCleanup(true); if (scale9Image != batchnode) { scale9Image = batchnode; } scale9Image.RemoveAllChildrenWithCleanup(true); m_capInsets = capInsets; // If there is no given rect if (rect.Equals(CCRect.Zero)) { // Get the texture size as original CCSize textureSize = scale9Image.TextureAtlas.Texture.ContentSize; rect = new CCRect(0, 0, textureSize.Width, textureSize.Height); } // Set the given rect's size as original size m_spriteRect = rect; m_originalSize = rect.Size; m_preferredSize = m_originalSize; m_capInsetsInternal = capInsets; // Get the image edges float l = rect.Origin.X; float t = rect.Origin.Y; float h = rect.Size.Height; float w = rect.Size.Width; // If there is no specified center region if (m_capInsetsInternal.Equals(CCRect.Zero)) { // Apply the 3x3 grid format if (rotated) { m_capInsetsInternal = new CCRect(l + h / 3, t + w / 3, w / 3, h / 3); } else { m_capInsetsInternal = new CCRect(l + w / 3, t + h / 3, w / 3, h / 3); } } // // Set up the image // if (rotated) { // Sprite frame is rotated // Centre centre = new CCSprite(); centre.InitWithTexture(scale9Image.Texture, m_capInsetsInternal, true); scale9Image.AddChild(centre, 0, (int)Positions.pCentre); // Bottom bottom = new CCSprite(); bottom.InitWithTexture(scale9Image.Texture, new CCRect(l, m_capInsetsInternal.Origin.Y, m_capInsetsInternal.Size.Width, m_capInsetsInternal.Origin.X - l), rotated ); scale9Image.AddChild(bottom, 1, (int)Positions.pBottom); // Top top = new CCSprite(); top.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X + m_capInsetsInternal.Size.Height, m_capInsetsInternal.Origin.Y, m_capInsetsInternal.Size.Width, h - m_capInsetsInternal.Size.Height - (m_capInsetsInternal.Origin.X - l)), rotated ); scale9Image.AddChild(top, 1, (int)Positions.pTop); // Right right = new CCSprite(); right.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X, m_capInsetsInternal.Origin.Y + m_capInsetsInternal.Size.Width, w - (m_capInsetsInternal.Origin.Y - t) - m_capInsetsInternal.Size.Width, m_capInsetsInternal.Size.Height), rotated ); scale9Image.AddChild(right, 1, (int)Positions.pRight); // Left left = new CCSprite(); left.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X, t, m_capInsetsInternal.Origin.Y - t, m_capInsetsInternal.Size.Height), rotated ); scale9Image.AddChild(left, 1, (int)Positions.pLeft); // Top right topRight = new CCSprite(); topRight.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X + m_capInsetsInternal.Size.Height, m_capInsetsInternal.Origin.Y + m_capInsetsInternal.Size.Width, w - (m_capInsetsInternal.Origin.Y - t) - m_capInsetsInternal.Size.Width, h - m_capInsetsInternal.Size.Height - (m_capInsetsInternal.Origin.X - l)), rotated ); scale9Image.AddChild(topRight, 2, (int)Positions.pTopRight); // Top left topLeft = new CCSprite(); topLeft.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X + m_capInsetsInternal.Size.Height, t, m_capInsetsInternal.Origin.Y - t, h - m_capInsetsInternal.Size.Height - (m_capInsetsInternal.Origin.X - l)), rotated ); scale9Image.AddChild(topLeft, 2, (int)Positions.pTopLeft); // Bottom right bottomRight = new CCSprite(); bottomRight.InitWithTexture(scale9Image.Texture, new CCRect(l, m_capInsetsInternal.Origin.Y + m_capInsetsInternal.Size.Width, w - (m_capInsetsInternal.Origin.Y - t) - m_capInsetsInternal.Size.Width, m_capInsetsInternal.Origin.X - l), rotated ); scale9Image.AddChild(bottomRight, 2, (int)Positions.pBottomRight); // Bottom left bottomLeft = new CCSprite(); bottomLeft.InitWithTexture(scale9Image.Texture, new CCRect(l, t, m_capInsetsInternal.Origin.Y - t, m_capInsetsInternal.Origin.X - l), rotated ); scale9Image.AddChild(bottomLeft, 2, (int)Positions.pBottomLeft); } else { // Sprite frame is not rotated // Centre centre = new CCSprite(); centre.InitWithTexture(scale9Image.Texture, m_capInsetsInternal, rotated); scale9Image.AddChild(centre, 0, (int)Positions.pCentre); // Top top = new CCSprite(); top.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X, t, m_capInsetsInternal.Size.Width, m_capInsetsInternal.Origin.Y - t), rotated ); scale9Image.AddChild(top, 1, (int)Positions.pTop); // Bottom bottom = new CCSprite(); bottom.InitWithTexture(scale9Image.Texture, new CCRect(m_capInsetsInternal.Origin.X, m_capInsetsInternal.Origin.Y + m_capInsetsInternal.Size.Height, m_capInsetsInternal.Size.Width, h - (m_capInsetsInternal.Origin.Y - t + m_capInsetsInternal.Size.Height)), rotated); scale9Image.AddChild(bottom, 1, (int)Positions.pBottom); // Left left = new CCSprite(); left.InitWithTexture(scale9Image.Texture, new CCRect( l, m_capInsetsInternal.Origin.Y, m_capInsetsInternal.Origin.X - l, m_capInsetsInternal.Size.Height), rotated); scale9Image.AddChild(left, 1, (int)Positions.pLeft); // Right right = new CCSprite(); right.InitWithTexture(scale9Image.Texture, new CCRect( m_capInsetsInternal.Origin.X + m_capInsetsInternal.Size.Width, m_capInsetsInternal.Origin.Y, w - (m_capInsetsInternal.Origin.X - l + m_capInsetsInternal.Size.Width), m_capInsetsInternal.Size.Height), rotated); scale9Image.AddChild(right, 1, (int)Positions.pRight); // Top left topLeft = new CCSprite(); topLeft.InitWithTexture(scale9Image.Texture, new CCRect( l, t, m_capInsetsInternal.Origin.X - l, m_capInsetsInternal.Origin.Y - t), rotated); scale9Image.AddChild(topLeft, 2, (int)Positions.pTopLeft); // Top right topRight = new CCSprite(); topRight.InitWithTexture(scale9Image.Texture, new CCRect( m_capInsetsInternal.Origin.X + m_capInsetsInternal.Size.Width, t, w - (m_capInsetsInternal.Origin.X - l + m_capInsetsInternal.Size.Width), m_capInsetsInternal.Origin.Y - t), rotated); scale9Image.AddChild(topRight, 2, (int)Positions.pTopRight); // Bottom left bottomLeft = new CCSprite(); bottomLeft.InitWithTexture(scale9Image.Texture, new CCRect( l, m_capInsetsInternal.Origin.Y + m_capInsetsInternal.Size.Height, m_capInsetsInternal.Origin.X - l, h - (m_capInsetsInternal.Origin.Y - t + m_capInsetsInternal.Size.Height)), rotated); scale9Image.AddChild(bottomLeft, 2, (int)Positions.pBottomLeft); // Bottom right bottomRight = new CCSprite(); bottomRight.InitWithTexture(scale9Image.Texture, new CCRect( m_capInsetsInternal.Origin.X + m_capInsetsInternal.Size.Width, m_capInsetsInternal.Origin.Y + m_capInsetsInternal.Size.Height, w - (m_capInsetsInternal.Origin.X - l + m_capInsetsInternal.Size.Width), h - (m_capInsetsInternal.Origin.Y - t + m_capInsetsInternal.Size.Height)), rotated); scale9Image.AddChild(bottomRight, 2, (int)Positions.pBottomRight); } ContentSize = rect.Size; AddChild(scale9Image); if (m_bSpritesGenerated) { // Restore color and opacity Opacity = opacity; Color = color; } m_bSpritesGenerated = true; return(true); }
public void SetNormalSpriteFrame(CCSpriteFrame frame) { NormalImage = new CCSprite(frame); }
public bool UpdateWithBatchNode(CCSpriteBatchNode batchnode, CCRect rect, bool rotated, CCRect capInsets) { var opacity = Opacity; var color = Color; // Release old sprites RemoveAllChildrenWithCleanup(true); _scale9Image = batchnode; _scale9Image.RemoveAllChildrenWithCleanup(true); m_capInsets = capInsets; // If there is no given rect if (rect.Equals(CCRect.Zero)) { // Get the texture size as original CCSize textureSize = _scale9Image.TextureAtlas.Texture.ContentSize; rect = new CCRect(0, 0, textureSize.Width, textureSize.Height); } // Set the given rect's size as original size m_spriteRect = rect; m_originalSize = rect.Size; m_preferredSize = m_originalSize; m_capInsetsInternal = capInsets; float h = rect.Size.Height; float w = rect.Size.Width; // If there is no specified center region if (m_capInsetsInternal.Equals(CCRect.Zero)) { m_capInsetsInternal = new CCRect(w / 3, h / 3, w / 3, h / 3); } float left_w = m_capInsetsInternal.Origin.X; float center_w = m_capInsetsInternal.Size.Width; float right_w = rect.Size.Width - (left_w + center_w); float top_h = m_capInsetsInternal.Origin.Y; float center_h = m_capInsetsInternal.Size.Height; float bottom_h = rect.Size.Height - (top_h + center_h); // calculate rects // ... top row float x = 0.0f; float y = 0.0f; // top left CCRect lefttopbounds = new CCRect(x, y, left_w, top_h); // top center x += left_w; CCRect centertopbounds = new CCRect(x, y, center_w, top_h); // top right x += center_w; CCRect righttopbounds = new CCRect(x, y, right_w, top_h); // ... center row x = 0.0f; y = 0.0f; y += top_h; // center left CCRect leftcenterbounds = new CCRect(x, y, left_w, center_h); // center center x += left_w; CCRect centerbounds = new CCRect(x, y, center_w, center_h); // center right x += center_w; CCRect rightcenterbounds = new CCRect(x, y, right_w, center_h); // ... bottom row x = 0.0f; y = 0.0f; y += top_h; y += center_h; // bottom left CCRect leftbottombounds = new CCRect(x, y, left_w, bottom_h); // bottom center x += left_w; CCRect centerbottombounds = new CCRect(x, y, center_w, bottom_h); // bottom right x += center_w; CCRect rightbottombounds = new CCRect(x, y, right_w, bottom_h); if (!rotated) { // CCLog("!rotated"); CCAffineTransform t = CCAffineTransform.Identity; t = CCAffineTransform.Translate(t, rect.Origin.X, rect.Origin.Y); centerbounds = CCAffineTransform.Transform(centerbounds, t); rightbottombounds = CCAffineTransform.Transform(rightbottombounds, t); leftbottombounds = CCAffineTransform.Transform(leftbottombounds, t); righttopbounds = CCAffineTransform.Transform(righttopbounds, t); lefttopbounds = CCAffineTransform.Transform(lefttopbounds, t); rightcenterbounds = CCAffineTransform.Transform(rightcenterbounds, t); leftcenterbounds = CCAffineTransform.Transform(leftcenterbounds, t); centerbottombounds = CCAffineTransform.Transform(centerbottombounds, t); centertopbounds = CCAffineTransform.Transform(centertopbounds, t); // Centre _centre = new CCSprite(); _centre.InitWithTexture(_scale9Image.Texture, centerbounds); _scale9Image.AddChild(_centre, 0, (int)Positions.Centre); // Top _top = new CCSprite(); _top.InitWithTexture(_scale9Image.Texture, centertopbounds); _scale9Image.AddChild(_top, 1, (int)Positions.Top); // Bottom _bottom = new CCSprite(); _bottom.InitWithTexture(_scale9Image.Texture, centerbottombounds); _scale9Image.AddChild(_bottom, 1, (int)Positions.Bottom); // Left _left = new CCSprite(); _left.InitWithTexture(_scale9Image.Texture, leftcenterbounds); _scale9Image.AddChild(_left, 1, (int)Positions.Left); // Right _right = new CCSprite(); _right.InitWithTexture(_scale9Image.Texture, rightcenterbounds); _scale9Image.AddChild(_right, 1, (int)Positions.Right); // Top left _topLeft = new CCSprite(); _topLeft.InitWithTexture(_scale9Image.Texture, lefttopbounds); _scale9Image.AddChild(_topLeft, 2, (int)Positions.TopLeft); // Top right _topRight = new CCSprite(); _topRight.InitWithTexture(_scale9Image.Texture, righttopbounds); _scale9Image.AddChild(_topRight, 2, (int)Positions.TopRight); // Bottom left _bottomLeft = new CCSprite(); _bottomLeft.InitWithTexture(_scale9Image.Texture, leftbottombounds); _scale9Image.AddChild(_bottomLeft, 2, (int)Positions.BottomLeft); // Bottom right _bottomRight = new CCSprite(); _bottomRight.InitWithTexture(_scale9Image.Texture, rightbottombounds); _scale9Image.AddChild(_bottomRight, 2, (int)Positions.BottomRight); } else { // set up transformation of coordinates // to handle the case where the sprite is stored rotated // in the spritesheet // CCLog("rotated"); CCAffineTransform t = CCAffineTransform.Identity; CCRect rotatedcenterbounds = centerbounds; CCRect rotatedrightbottombounds = rightbottombounds; CCRect rotatedleftbottombounds = leftbottombounds; CCRect rotatedrighttopbounds = righttopbounds; CCRect rotatedlefttopbounds = lefttopbounds; CCRect rotatedrightcenterbounds = rightcenterbounds; CCRect rotatedleftcenterbounds = leftcenterbounds; CCRect rotatedcenterbottombounds = centerbottombounds; CCRect rotatedcentertopbounds = centertopbounds; t = CCAffineTransform.Translate(t, rect.Size.Height + rect.Origin.X, rect.Origin.Y); t = CCAffineTransform.Rotate(t, 1.57079633f); centerbounds = CCAffineTransform.Transform(centerbounds, t); rightbottombounds = CCAffineTransform.Transform(rightbottombounds, t); leftbottombounds = CCAffineTransform.Transform(leftbottombounds, t); righttopbounds = CCAffineTransform.Transform(righttopbounds, t); lefttopbounds = CCAffineTransform.Transform(lefttopbounds, t); rightcenterbounds = CCAffineTransform.Transform(rightcenterbounds, t); leftcenterbounds = CCAffineTransform.Transform(leftcenterbounds, t); centerbottombounds = CCAffineTransform.Transform(centerbottombounds, t); centertopbounds = CCAffineTransform.Transform(centertopbounds, t); rotatedcenterbounds.Origin = centerbounds.Origin; rotatedrightbottombounds.Origin = rightbottombounds.Origin; rotatedleftbottombounds.Origin = leftbottombounds.Origin; rotatedrighttopbounds.Origin = righttopbounds.Origin; rotatedlefttopbounds.Origin = lefttopbounds.Origin; rotatedrightcenterbounds.Origin = rightcenterbounds.Origin; rotatedleftcenterbounds.Origin = leftcenterbounds.Origin; rotatedcenterbottombounds.Origin = centerbottombounds.Origin; rotatedcentertopbounds.Origin = centertopbounds.Origin; // Centre _centre = new CCSprite(); _centre.InitWithTexture(_scale9Image.Texture, rotatedcenterbounds, true); _scale9Image.AddChild(_centre, 0, (int)Positions.Centre); // Top _top = new CCSprite(); _top.InitWithTexture(_scale9Image.Texture, rotatedcentertopbounds, true); _scale9Image.AddChild(_top, 1, (int)Positions.Top); // Bottom _bottom = new CCSprite(); _bottom.InitWithTexture(_scale9Image.Texture, rotatedcenterbottombounds, true); _scale9Image.AddChild(_bottom, 1, (int)Positions.Bottom); // Left _left = new CCSprite(); _left.InitWithTexture(_scale9Image.Texture, rotatedleftcenterbounds, true); _scale9Image.AddChild(_left, 1, (int)Positions.Left); // Right _right = new CCSprite(); _right.InitWithTexture(_scale9Image.Texture, rotatedrightcenterbounds, true); _scale9Image.AddChild(_right, 1, (int)Positions.Right); // Top left _topLeft = new CCSprite(); _topLeft.InitWithTexture(_scale9Image.Texture, rotatedlefttopbounds, true); _scale9Image.AddChild(_topLeft, 2, (int)Positions.TopLeft); // Top right _topRight = new CCSprite(); _topRight.InitWithTexture(_scale9Image.Texture, rotatedrighttopbounds, true); _scale9Image.AddChild(_topRight, 2, (int)Positions.TopRight); // Bottom left _bottomLeft = new CCSprite(); _bottomLeft.InitWithTexture(_scale9Image.Texture, rotatedleftbottombounds, true); _scale9Image.AddChild(_bottomLeft, 2, (int)Positions.BottomLeft); // Bottom right _bottomRight = new CCSprite(); _bottomRight.InitWithTexture(_scale9Image.Texture, rotatedrightbottombounds, true); _scale9Image.AddChild(_bottomRight, 2, (int)Positions.BottomRight); } ContentSize = rect.Size; AddChild(_scale9Image); if (m_bSpritesGenerated) { // Restore color and opacity Opacity = opacity; Color = color; } m_bSpritesGenerated = true; return(true); }
public void SetDisabledSpriteFrame(CCSpriteFrame frame) { DisabledImage = new CCSprite(frame); }
private void UpdateAtlasIndex(CCSprite sprite, ref int curIndex) { int count = 0; CCRawList <CCNode> pArray = sprite.Children; if (pArray != null) { count = pArray.Count; } int oldIndex = 0; if (count == 0) { oldIndex = sprite.AtlasIndex; sprite.AtlasIndex = curIndex; sprite.m_uOrderOfArrival = 0; if (oldIndex != curIndex) { Swap(oldIndex, curIndex); } curIndex++; } else { bool needNewIndex = true; if (pArray.Elements[0].m_nZOrder >= 0) { //all children are in front of the parent oldIndex = sprite.AtlasIndex; sprite.AtlasIndex = curIndex; sprite.m_uOrderOfArrival = 0; if (oldIndex != curIndex) { Swap(oldIndex, curIndex); } curIndex++; needNewIndex = false; } for (int i = 0; i < count; i++) { var child = (CCSprite)pArray.Elements[i]; if (needNewIndex && child.m_nZOrder >= 0) { oldIndex = sprite.AtlasIndex; sprite.AtlasIndex = curIndex; sprite.m_uOrderOfArrival = 0; if (oldIndex != curIndex) { Swap(oldIndex, curIndex); } curIndex++; needNewIndex = false; } UpdateAtlasIndex(child, ref curIndex); } if (needNewIndex) { //all children have a zOrder < 0) oldIndex = sprite.AtlasIndex; sprite.AtlasIndex = curIndex; sprite.m_uOrderOfArrival = 0; if (oldIndex != curIndex) { Swap(oldIndex, curIndex); } curIndex++; } } }
public void AddChild(CCSprite node, int z, CCPoint r, CCPoint p, CCPoint s) { AddChild(node, z, r, p, s, CCPoint.Zero); }
/** Creates a progress timer with the sprite as the shape the timer goes through */ public CCProgressTimer(CCSprite sp) { InitWithSprite(sp); }
public override bool Init() { if (base.Init()) { TouchEnabled = true; // Cache the sprites CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile( "extensions/CCControlColourPickerSpriteSheet.plist"); // Create the sprite batch node var spriteSheet = new CCSpriteBatchNode("extensions/CCControlColourPickerSpriteSheet.png"); AddChild(spriteSheet); // MIPMAP // ccTexParams params = {GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT}; /* Comment next line to avoid something like mosaic in 'ControlExtensionTest', * especially the display of 'huePickerBackground.png' when in 800*480 window size with 480*320 design resolution and hd(960*640) resources. */ // spriteSheet->getTexture()->setAliasTexParameters(); // spriteSheet->getTexture()->setTexParameters(¶ms); // spriteSheet->getTexture()->generateMipmap(); // Init default color _hsv.h = 0; _hsv.s = 0; _hsv.v = 0; // Add image _background = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, CCPoint.Zero, new CCPoint(0.5f, 0.5f)); CCPoint backgroundPointZero = _background.Position - new CCPoint(_background.ContentSize.Width / 2, _background.ContentSize.Height / 2); // Setup panels float hueShift = 8; float colourShift = 28; _huePicker = new CCControlHuePicker(); _huePicker.InitWithTargetAndPos(spriteSheet, new CCPoint(backgroundPointZero.X + hueShift, backgroundPointZero.Y + hueShift)); _colourPicker = new CCControlSaturationBrightnessPicker(); _colourPicker.InitWithTargetAndPos(spriteSheet, new CCPoint(backgroundPointZero.X + colourShift, backgroundPointZero.Y + colourShift)); // Setup events _huePicker.AddTargetWithActionForControlEvents(this, HueSliderValueChanged, CCControlEvent.ValueChanged); _colourPicker.AddTargetWithActionForControlEvents(this, ColourSliderValueChanged, CCControlEvent.ValueChanged); // Set defaults UpdateHueAndControlPicker(); AddChild(_huePicker); AddChild(_colourPicker); // Set content size ContentSize = _background.ContentSize; return(true); } return(false); }
private float GetLetterPosXRight(CCSprite sp) { return(sp.Position.X * m_fScaleX + (sp.ContentSize.Width * m_fScaleX * sp.AnchorPoint.X)); }