Beispiel #1
0
        private void PopAnimation(CCLayer layer)
        {
            //play pop sound here
            this.StopAllActions();
            var pop = new CCParticleExplosion(this.Position);

            pop.EndColor           = new CCColor4F(CCColor3B.Yellow);
            pop.AutoRemoveOnFinish = true;
            pop.BlendAdditive      = true;
            pop.Life         = 1.5F;
            pop.EmissionRate = 80;
            pop.StartColor   = new CCColor4F(color);
            layer.AddChild(pop);
            CCSimpleAudioEngine.SharedEngine.PlayEffect("sounds/pop");
        }
Beispiel #2
0
        public void Explode()
        {
            // create explosion particle system
            var explosion = new CCParticleExplosion(PositionWorldspace);

            explosion.Speed              = 500.0f;
            explosion.StartSize          = 30.0f;
            explosion.EndSize            = 150.0f;
            explosion.TotalParticles     = 200;
            explosion.AutoRemoveOnFinish = true;
            Parent.AddChild(explosion);

            // play explose sound effect
            CCAudioEngine.SharedEngine.PlayEffect("Explosion");
        }
        bool HandleFunc()
        {
            explosion.ResetSystem();
            var explodo = new CCParticleExplosion(CCPoint.Zero);

            explodo.StartColor = new CCColor4F(CCColor3B.Red);
            explodo.EndColor   = new CCColor4F(CCColor3B.Black);
            //startLocation = new CCPoint(XLoc, YLoc);
            // XLoc += 10;
            /// YLoc += 10;
            explodo.Position = startLocation;

            layer.AddChild(explodo);
            return(true);
        }
Beispiel #4
0
        private void PopAnimation(CCLayer layer)
        {
            StopAllActions();
            var pop = new CCParticleExplosion(Position)
            {
                EndColor           = new CCColor4F(CCColor3B.Yellow),
                AutoRemoveOnFinish = true,
                BlendAdditive      = true,
                Life         = 1.5F,
                EmissionRate = 80,
                StartColor   = new CCColor4F(BubbleColor)
            };

            layer.AddChild(pop);
            //CCAudioEngine.SharedEngine.PlayEffect ("sounds/pop");
        }
Beispiel #5
0
        private void ReachedTargetZone()
        {
            _burst       = new CCParticleExplosion(_targetZone.Position, CCEmitterMode.Gravity);
            _burst.Speed = 75;
            AddChild(_burst);

            Random rnd = new Random();
            int    x   = rnd.Next(100, (int)_bounds.MaxX - 100);
            int    y   = rnd.Next(100, (int)_bounds.MaxY - 100);

            _targetZone.Position = new CCPoint(x, y);

            RemoveChild(_line);

            _line = new CCDrawNode();
            AddChild(_line);
        }
 public static new CCParticleExplosion Create()
 {
     var ret = new CCParticleExplosion();
     ret.InitWithTotalParticles(700);
     return ret;
 }
        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;
            }
        }