public override void OnEnter() { base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size; Emitter = new CCParticleExplosion(MidWindowPoint); Background.AddChild(Emitter, 10); Emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_stars1); Emitter.AutoRemoveOnFinish = true; SetEmitterPosition(); }
void Explode(CCPoint pt) { var explosion = new CCParticleExplosion (pt); //TODO: manage "better" for performance when "many" particles explosion.TotalParticles = 10; explosion.AutoRemoveOnFinish = true; AddChild (explosion); }
void RunGameLogic(float frameTimeInSeconds) { // This is a linear approximation, so not 100% accurate. ballYVelocity += frameTimeInSeconds * -gravity; ballSprite.PositionX += ballXVelocity * frameTimeInSeconds; ballSprite.PositionY += ballYVelocity * frameTimeInSeconds; // Check if the two CCSprites overlap... bool doesBallOverlapPaddle = ballSprite.BoundingBoxTransformedToParent.IntersectsRect( paddleSprite.BoundingBoxTransformedToParent); // ... and if the ball is moving downward. bool isMovingDownward = ballYVelocity < 0; if (doesBallOverlapPaddle && isMovingDownward) { // First let's invert the velocity: ballYVelocity *= -1; // Then let's assign a random value to the ball's x velocity: const float minXVelocity = -600; const float maxXVelocity = 600; ballXVelocity = CCRandom.GetRandomFloat (minXVelocity, maxXVelocity); score++; scoreLabel.Text = "Score: " + score; var effect = new CCParticleExplosion(ballSprite.Position) { AutoRemoveOnFinish = true, EmissionRate = 100 }; AddChild(effect); CCSimpleAudioEngine.SharedEngine.PlayEffect("tennis_ball"); } // First let’s get the ball position: float ballRight = ballSprite.BoundingBoxTransformedToParent.MaxX; float ballLeft = ballSprite.BoundingBoxTransformedToParent.MinX; // Then let’s get the screen edges. float screenRight = VisibleBoundsWorldspace.MaxX; float screenLeft = VisibleBoundsWorldspace.MinX; // Check if the ball is either too far to the right or left: bool shouldReflectXVelocity = (ballRight > screenRight && ballXVelocity > 0) || (ballLeft < screenLeft && ballXVelocity < 0); if (shouldReflectXVelocity) { ballXVelocity *= -1; } if (ballSprite.PositionY < VisibleBoundsWorldspace.MinY) { ballSprite.PositionY = VisibleBoundsWorldspace.MaxY; if (highestScore < score) { highestScore = score; highestScoreLabel.Text = "Highest Score: " + highestScore; } score = 0; scoreLabel.Text = "Score: 0"; ballXVelocity = 0; ballYVelocity = 0; } }
void StartExplosion(CCNode monster, object arg2) { var particleExplosion = new CCParticleExplosion(monster.Position) { TotalParticles = 809, Texture = CCTextureCache.SharedTextureCache.AddImage("textureRed.png"), Life = 0.0f, LifeVar = 0.708f, StartSize = 40, StartSizeVar = 38, EndSize = 14, EndSizeVar = 0, Angle = 360, AngleVar = 360, Speed = 243, SpeedVar = 1 }; particleExplosion.Gravity = new CCPoint(1.15f, 1.58f); particleExplosion.StartColor = new CCColor4F(0.89f, 0.56f, 0.36f, 1.0f); particleExplosion.EndColor = new CCColor4F(1.0f,0.0f,0.0f,1.0f); AddChild(particleExplosion); particleExplosion.ResetSystem(); }
void Explode(CCPoint pt) { string[] effectArray = {"exp1.plist", "boom.plist", "starTest.plist"}; // string[] effectArray = {"exp1.plist"}; foreach (var effectName in effectArray) { var effect = new CCParticleSystemQuad (effectName); effect.Position = pt; AddChild (effect, 10000); } return; var explosion = new CCParticleExplosion (pt); //TODO: manage "better" for performance when "many" particles explosion.TotalParticles = 10; explosion.AutoRemoveOnFinish = true; AddChild (explosion); }