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)); sprite.Position = (new CCPoint(p.X, p.Y)); BatchNode.AddChild(sprite); CCFiniteTimeAction 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); CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse(); CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
void AddNewSprite() { CCSize s = Layer.VisibleBoundsWorldspace.Size; CCPoint p = new CCPoint((float)(CCRandom.NextDouble() * s.Width), (float)(CCRandom.NextDouble() * s.Height)); CCSpriteBatchNode batch = (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(batch.Texture, new CCRect(x, y, 85, 121)); batch.AddChild(sprite); sprite.Position = (new CCPoint(p.X, p.Y)); CCFiniteTimeAction action; 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); CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse(); CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
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; CCFiniteTimeAction 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(); CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse(); CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
public ActionBlink() { action1 = new CCBlink(2, 10); action2 = new CCBlink(2, 5); }