Example #1
0
        /// <summary>
        /// Иговой цикл на экране с меню - падающие крисстальчики на фоне
        /// </summary>
        private void UpdateGems()
        {
            if (CCRandom.NextDouble() < 0.02)
            {
                var type   = CCRandom.GetRandomInt(0, 4);
                var sprite = new CCSprite("crystalscrystals/" + type + ".png");
                var x      = CCRandom.NextDouble() * CCDirector.SharedDirector.WinSize.Width + Constants.KGemSize / 2;
                var y      = CCDirector.SharedDirector.WinSize.Height + Constants.KGemSize / 2;
                var scale  = 0.2 + 0.8 * CCRandom.NextDouble();
                var speed  = 2 * scale * Constants.KGemSize / 40;
                sprite.Position = new CCPoint((float)x, (float)y);
                sprite.Scale    = (float)scale;
                _fallingGems.Add(sprite, (float)speed);
                _background.AddChild(sprite);
            }

            var gems = _fallingGems.Keys.ToArray();

            foreach (var gem in gems)
            {
                var speed = _fallingGems[gem];
                var pos   = gem.Position;
                gem.Position = pos - new CCPoint(0, speed);
                if (pos.Y < -Constants.KGemSize / 2)
                {
                    _background.RemoveChild(gem, true);
                    _fallingGems.Remove(gem);
                }
            }
        }
Example #2
0
        public override void Update(float time)
        {
            int i, j;

            var doubleRange = Range * 2;

            for (i = 0; i < GridSize.X; ++i)
            {
                for (j = 0; j < GridSize.Y; ++j)
                {
                    CCQuad3 coords = OriginalTile(i, j);
                    // X
                    coords.BottomLeft.X  += (CCRandom.Next() % doubleRange) - Range;
                    coords.BottomRight.X += (CCRandom.Next() % doubleRange) - Range;
                    coords.TopLeft.X     += (CCRandom.Next() % doubleRange) - Range;
                    coords.TopRight.X    += (CCRandom.Next() % doubleRange) - Range;

                    // Y
                    coords.BottomLeft.Y  += (CCRandom.Next() % doubleRange) - Range;
                    coords.BottomRight.Y += (CCRandom.Next() % doubleRange) - Range;
                    coords.TopLeft.Y     += (CCRandom.Next() % doubleRange) - Range;
                    coords.TopRight.Y    += (CCRandom.Next() % doubleRange) - Range;

                    if (ShakeZ)
                    {
                        coords.BottomLeft.Z  += (CCRandom.Next() % doubleRange) - Range;
                        coords.BottomRight.Z += (CCRandom.Next() % doubleRange) - Range;
                        coords.TopLeft.Z     += (CCRandom.Next() % doubleRange) - Range;
                        coords.TopRight.Z    += (CCRandom.Next() % doubleRange) - Range;
                    }

                    SetTile(i, j, ref coords);
                }
            }
        }
        public CCPhysicsSprite addGrossiniAtPosition(CCPoint location)
        {
            int posx, posy;

            posx = CCRandom.Next() * 200;
            posy = CCRandom.Next() * 200;

            posx = (Math.Abs(posx) % 4) * 85;
            posy = (Math.Abs(posy) % 3) * 121;

            CCPhysicsSprite sp = new CCPhysicsSprite(spriteTexture.Texture, new CCRect(posx, posy, 85, 121));

            cpBB verts = new cpBB(-24, -54, 24, 54);

            var body = new cpBody(1, cp.MomentForBox2(1, new cpBB(-24, -54, 24, 54)));             //);

            body.SetPosition(new cpVect(posx, posy));
            space.AddBody(body);

            var shape = cpPolyShape.BoxShape2(body, verts, 0);

            shape.e = .5f;
            shape.u = .5f;
            space.AddShape(shape);

            sp.Body = body;

            AddChild(sp);
            sp.Position = location;


            return(sp);
        }
Example #4
0
        //---------------------------------------------------------------------------------------------------------
        // GetRandomPosition
        //---------------------------------------------------------------------------------------------------------
        // Get a position based on the index and sprite size
        //---------------------------------------------------------------------------------------------------------
        static CCPoint GetRandomPosition(int xIndex, int yIndex)
        {
            double rndX = CCRandom.GetRandomFloat((xIndex * CELL_DIMS_HALF * 2) + (SCREEN_X_MARGIN + CELL_DIMS_HALF - CELL_CENTER_ZONE_HALF), (xIndex * CELL_DIMS_HALF * 2) + (SCREEN_X_MARGIN + CELL_DIMS_HALF + CELL_CENTER_ZONE_HALF));
            double rndY = CCRandom.GetRandomFloat((yIndex * CELL_DIMS_HALF * 2) + (SCREEN_Y_MARGIN + CELL_DIMS_HALF - CELL_CENTER_ZONE_HALF), (yIndex * CELL_DIMS_HALF * 2) + (SCREEN_Y_MARGIN + CELL_DIMS_HALF + CELL_CENTER_ZONE_HALF));

            return(new CCPoint((float)rndX, (float)rndY));
        }
Example #5
0
        private void performanceScale(CCSprite pSprite)
        {
            CCSize size = CCDirector.SharedDirector.WinSize;

            pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height));
            pSprite.Scale    = CCRandom.Float_0_1() * 100 / 50;
        }
Example #6
0
        // made public for debugging, may make it private later:
        private void Spawn()
        {
            float gateMiddlePoint = Layer.ContentSize.Width / 2;

            gateMiddlePoint = CCRandom.GetRandomFloat(0 + GameCoefficients.FruitRadius + GameCoefficients.gateRadius * 2, Layer.ContentSize.Width - GameCoefficients.FruitRadius - GameCoefficients.gateRadius * 2);
            //tao red dau tien ben trai
            createNewFruitRed(0 + GameCoefficients.FruitRadius);
            for (float i = GameCoefficients.FruitRadius; i < Layer.ContentSize.Width - GameCoefficients.FruitRadius; i += GameCoefficients.FruitRadius * 2)
            //for (float i = 0; i < Layer.ContentSize.Width + GameCoefficients.FruitRadius; i += GameCoefficients.FruitRadius * 2)
            {
                ////tao canh cua de khi vuot qua dau tien la sac dinh tam bang gateMiddlePoint sau do la tao fruit(vatcan) tru di ban kinh cua gate
                //gateMiddlePoint = Layer.ContentSize.Width / 2; //Layer.ContentSize.Width / 2;


                //createNewFruitRed(gateMiddlePoint);
                if (i < gateMiddlePoint - GameCoefficients.gateRadius * 2 || i > gateMiddlePoint + GameCoefficients.gateRadius * 2)
                {
                    createNewFruitRed(i);
                }
                else
                {
                    creaNewFruitYellow(i);
                }
                //if ((0 < i && i < gateMiddlePoint - GameCoefficients.gateRadius * 2) || (i > gateMiddlePoint + GameCoefficients.gateRadius * 2 && i < Layer.ContentSize.Width))
                //{
                //    createNewFruitRed(i);
                //}
                //else if (i != 0 + GameCoefficients.FruitRadius)//khong tao yellow dau tien ben trai vi nhu the se de len mau do da tao len dau tien
                //{
                //    creaNewFruitYellow(i);
                //}
            }
            //tao red cuoi cung ben phai
            createNewFruitRed(Layer.ContentSize.Width - GameCoefficients.FruitRadius);
        }
Example #7
0
        public override void updateQuantityOfNodes()
        {
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            // 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));
                    AddChild(sprite);
                    sprite.Position = new CCPoint(CCRandom.Next() * s.Width, CCRandom.Next() * s.Height);
                }
            }

            // decrease nodes
            else if (currentQuantityOfNodes > quantityOfNodes)
            {
                StartTimer();
                for (int i = 0; i < (currentQuantityOfNodes - quantityOfNodes); i++)
                {
                    int index = currentQuantityOfNodes - i - 1;
                }
            }

            currentQuantityOfNodes = quantityOfNodes;
        }
Example #8
0
        public override void Update(float time)
        {
            if (Target == null)
            {
                return;
            }

            int i, j;

            for (i = 0; i < (GridSize.X + 1); ++i)
            {
                for (j = 0; j < (GridSize.Y + 1); ++j)
                {
                    CCVertex3F v = OriginalVertex(i, j);
                    v.X += (CCRandom.Next() % (Range * 2)) - Range;
                    v.Y += (CCRandom.Next() % (Range * 2)) - Range;

                    if (Shake)
                    {
                        v.Z += (CCRandom.Next() % (Range * 2)) - Range;
                    }

                    SetVertex(i, j, ref v);
                }
            }
        }
Example #9
0
        private void CreateTheButtons()
        {
            CCNode theLayer = GetChildByTag(kTheLayer);

            theLayer.RemoveAllChildrenByTag(kTheButtons);
            int space = 10; // px

            max_w = 0f;
            max_h = 0f;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    // Add the buttons
                    var button = standardButtonWithTitle(CCRandom.Next(30).ToString());
                    button.SetAdjustBackgroundImage(false);  // Tells the button that the background image must not be adjust
                    // It'll use the prefered size of the background image
                    button.Position = new CCPoint(button.ContentSize.Width / 2 + (button.ContentSize.Width + space) * i,
                                                  button.ContentSize.Height / 2 + (button.ContentSize.Height + space) * j);
                    theLayer.AddChild(button, kTheButtons);

                    max_w = Math.Max(button.ContentSize.Width * (i + 1) + space * i, max_w);
                    max_h = Math.Max(button.ContentSize.Height * (j + 1) + space * j, max_h);
                }
            }
        }
Example #10
0
        private void SpawnGroundUnit()
        {
            TimeInbetweenGroundUnitSpawns = CCRandom.GetRandomFloat(5f, 35f);
            CollisionEntity collisionEntity = null;

            var randomFloat = CCRandom.GetRandomFloat(0.0f, 3.0f);

            if (randomFloat > 2.0f)
            {
                collisionEntity = new Tree();
            }
            else if (randomFloat > 1.0f)
            {
                collisionEntity = new House();
            }
            else
            {
                collisionEntity = new Radar();
            }


            collisionEntity.Position = new CCPoint(_layer.VisibleBoundsWorldspace.MaxX + collisionEntity.GraphicWidth * 0.5f, _layer.VisibleBoundsWorldspace.MinY);


            if (EntitySpawned != null)
            {
                EntitySpawned(collisionEntity);
            }
        }
        public static CCPoint GetRandomPosition(CCSize spriteSize, CCSize visibleBoundsWorldspaceSize)
        {
            var randomX = CCRandom.Next(40, (int)visibleBoundsWorldspaceSize.Width - 40);
            var randomY = CCRandom.Next(40, (int)visibleBoundsWorldspaceSize.Height - 40);

            return(new CCPoint((float)randomX, (float)randomY));
        }
        private void performanceActions20(CCSprite pSprite)
        {
            CCSize size = CCDirector.SharedDirector.WinSize;

            if (CCRandom.Float_0_1() < 0.2f)
            {
                pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height));
            }
            else
            {
                pSprite.Position = new CCPoint(-1000, -1000);
            }

            float      period            = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCRotateBy rot               = new CCRotateBy(period, 360.0f * CCRandom.Float_0_1());
            var        rot_back          = (CCActionInterval)rot.Reverse();
            CCAction   permanentRotation = new CCRepeatForever(CCSequence.FromActions(rot, rot_back));

            pSprite.RunAction(permanentRotation);

            float            growDuration       = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCActionInterval grow               = new CCScaleBy(growDuration, 0.5f, 0.5f);
            CCAction         permanentScaleLoop = new CCRepeatForever(new CCSequence(grow, grow.Reverse()));

            pSprite.RunAction(permanentScaleLoop);
        }
Example #13
0
        private void resetHealth()
        {
            if (_fallingObjects.Count > 30)
            {
                return;
            }

            CCSprite health = (CCSprite)_healthPool[_healthPoolIndex];

            _healthPoolIndex++;
            if (_healthPoolIndex == _healthPool.Count)
            {
                _healthPoolIndex = 0;
            }

            int health_x        = CCRandom.GetRandomInt(0, 1000) % (int)(_screenSize.Width * 0.8f + _screenSize.Width * 0.1f);
            int health_target_x = CCRandom.GetRandomInt(0, 1000) % (int)(_screenSize.Width * 0.8f + _screenSize.Width * 0.1f);

            health.StopAllActions();
            health.Position = new CCPoint(health_x, _screenSize.Height + health.BoundingBox.Size.Height * 0.5f);

            //create action (swing, move to target, and call function when done)
            CCFiniteTimeAction sequence = new CCSequence(
                new CCMoveTo(_healthSpeed, new CCPoint(health_target_x, _screenSize.Height * 0.15f)),
                new CCCallFuncN(fallingObjectDone));

            health.Visible = true;
            health.RunAction(_swingHealth);
            health.RunAction(sequence);
            _fallingObjects.Add(health);
        }
Example #14
0
        public Bubble()
        {
            UniversalId++;
            id     = UniversalId;
            random = new Random();
            Scale  = 0.5f;
            switch (random.Next(0, 5))
            {
            case 0:
                color = color0;
                break;

            case 1:
                color = color1;
                break;

            case 2:
                color = color2;
                break;

            case 3:
                color = color3;
                break;

            case 4:
                color = color4;
                break;
            }

            colorF = new CCColor4F(color);
            var size = CCRandom.Next(25, 50);

            this.ContentSize = new CCSize(size, size);
            this.DrawSolidCircle(this.Position, (float)size, color);
        }
Example #15
0
        void StartScheduling()
        {
            Schedule(t => {
                if (ShouldEndGame())
                {
                    EndGame();
                    return;
                }
                visibleBubbles.Add(AddBubble());

                if (CCRandom.Next(0, 100) > 90)
                {
                    visibleBubbles.Add(AddBubble());
                }

                var left = (GAME_DURATION - elapsedTime);
                if (left < 10 && CCRandom.Next(0, 100) > 30)
                {
                    visibleBubbles.Add(AddBubble());
                }
            }, .5f);

            Schedule(t => CheckPop());

            // Schedule for method to be called every 0.1s
            Schedule(UpdateLayerGradient, 0.1f);
        }
Example #16
0
        private CCColor4B GetRandomColor(int maxColors)
        {
            CCColor4B bubbleColor;

            switch (CCRandom.Next(0, maxColors))
            {
            case 0:
                bubbleColor = Color0;
                break;

            case 1:
                bubbleColor = Color1;
                break;

            case 2:
                bubbleColor = Color2;
                break;

            case 3:
                bubbleColor = Color3;
                break;

            case 4:
                bubbleColor = Color4;
                break;
            }
            return(bubbleColor);
        }
Example #17
0
        private void StartScheduling()
        {
            Schedule(t => {
                if (ShouldEndGame)
                {
                    GameLayer.SetScore(_currentScore);
                    GameLayer.GameOver(_currentScore >= _gameConfiguration.ScoreToReach);
                    return;
                }
                _visibleBubbles.Add(AddBubble());

                if (CCRandom.Next(0, 100) > 90)
                {
                    _visibleBubbles.Add(AddBubble());
                }

                float timeLeft = (_gameConfiguration.MaxDuration - ElapsedTime);
                if (timeLeft < 10 && CCRandom.Next(0, 100) > 30)
                {
                    _visibleBubbles.Add(AddBubble());
                }
            }, .5f);

            Schedule(t => CheckPop());

            Schedule(UpdateLayerGradient, 0.1f);
        }
        private void performanceActions20(CCSprite pSprite)
        {
            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            if (CCRandom.Float_0_1() < 0.2f)
            {
                pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height));
            }
            else
            {
                pSprite.Position = new CCPoint(-1000, -1000);
            }

            float      period            = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCRotateBy rot               = new CCRotateBy(period, 360.0f * CCRandom.Float_0_1());
            var        rot_back          = (CCFiniteTimeAction)rot.Reverse();
            CCAction   permanentRotation = new CCRepeatForever(new CCSequence(rot, rot_back));

            pSprite.RunAction(permanentRotation);

            float growDuration      = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCFiniteTimeAction grow = new CCScaleBy(growDuration, 0.5f, 0.5f);
            CCAction           permanentScaleLoop = new CCRepeatForever(new CCSequence(grow, grow.Reverse()));

            pSprite.RunAction(permanentScaleLoop);
        }
Example #19
0
        // made public for debugging, may make it private later:
        private void Spawn()
        {
            var fruit = new Fruit();

            if (Layer == null)
            {
                throw new InvalidOperationException("Need to set Layer before spawning");
            }

            fruit.PositionX = CCRandom.GetRandomFloat(0 + fruit.Radius, Layer.ContentSize.Width - fruit.Radius);
            fruit.PositionY = Layer.ContentSize.Height + fruit.Radius;

            if (CCRandom.Float_0_1() > .5f)
            {
                fruit.FruitColor = FruitColor.Red;
            }
            else
            {
                fruit.FruitColor = FruitColor.Yellow;
            }


            if (FruitSpawned != null)
            {
                FruitSpawned(fruit);
            }
        }
Example #20
0
        CCPoint GetRandomPointY(float r)
        {
            double rnd     = CCRandom.NextDouble();
            double randomY = (rnd > 0.0f) ? rnd * VisibleBoundsWorldspace.Size.Height - r : r;

            return(new CCPoint((VisibleBoundsWorldspace.Size.Width - r), (float)randomY));
        }
Example #21
0
        public override void updateQuantityOfNodes()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // increase nodes
            if (currentQuantityOfNodes < quantityOfNodes)
            {
                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);
                }
            }

            // decrease nodes
            else if (currentQuantityOfNodes > quantityOfNodes)
            {
                for (int i = 0; i < (currentQuantityOfNodes - quantityOfNodes); i++)
                {
                    int index = currentQuantityOfNodes - i - 1;
                    batchNode.RemoveChildAtIndex(index, true);
                }
            }

            currentQuantityOfNodes = quantityOfNodes;
        }
        void AddBall()
        {
            int idx    = (CCRandom.Float_0_1() > .5 ? 0 : 1);
            int idy    = (CCRandom.Float_0_1() > .5 ? 0 : 1);
            var sprite = new CCPhysicsSprite(ballTexture, new CCRect(32 * idx, 32 * idy, 32, 32), PTM_RATIO);

            ballsBatch.AddChild(sprite);

            CCPoint p = GetRandomPosition(sprite.ContentSize);

            sprite.Position = new CCPoint(p.X, p.Y);
            var def = new b2BodyDef();

            def.position       = new b2Vec2(p.X / PTM_RATIO, p.Y / PTM_RATIO);
            def.linearVelocity = new b2Vec2(0.0f, -1.0f);
            def.type           = b2BodyType.b2_dynamicBody;
            b2Body body = world.CreateBody(def);

            var circle = new b2CircleShape();

            circle.Radius = 0.5f;

            var fd = new b2FixtureDef();

            fd.shape       = circle;
            fd.density     = 1f;
            fd.restitution = 0.85f;
            fd.friction    = 0f;
            body.CreateFixture(fd);

            sprite.PhysicsBody = body;

            Console.WriteLine("sprite batch node count = {0}", ballsBatch.ChildrenCount);
        }
Example #23
0
        public override void Update(float time)
        {
            int i, j;

            for (i = 0; i < m_sGridSize.X; ++i)
            {
                for (j = 0; j < m_sGridSize.Y; ++j)
                {
                    CCQuad3 coords = OriginalTile(new CCGridSize(i, j));
                    // X
                    coords.BottomLeft.X  += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.BottomRight.X += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.TopLeft.X     += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.TopRight.X    += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;

                    // Y
                    coords.BottomLeft.Y  += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.BottomRight.Y += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.TopLeft.Y     += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.TopRight.Y    += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;

                    if (m_bShakeZ)
                    {
                        coords.BottomLeft.Z  += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.BottomRight.Z += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.TopLeft.Z     += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.TopRight.Z    += (CCRandom.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    }

                    SetTile(new CCGridSize(i, j), ref coords);
                }
            }
        }
        private void performanceScale(CCSprite pSprite)
        {
            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height));
            pSprite.Scale    = CCRandom.Float_0_1() * 100 / 50;
        }
Example #25
0
        public void reset()
        {
            int localtag = 0;

            localtag++;

            // TO TRIGGER THE BUG:
            // remove the itself from parent from an action
            // The menu will be removed, but the instance will be alive
            // and then a new node will be allocated occupying the memory.
            // => CRASH BOOM BANG
            CCNode node = GetChildByTag(localtag - 1);

            CCLog.Log("Menu: %p", node);
            RemoveChild(node, false);
            //	[self removeChildByTag:localtag-1 cleanup:NO];

            CCMenuItem item1 = new CCMenuItemFont("One", menuCallback);

            CCLog.Log("MenuItemFont: %p", item1);
            CCMenuItem item2 = new CCMenuItemFont("Two", menuCallback);
            CCMenu     menu  = new CCMenu(item1, item2);

            menu.AlignItemsVertically();

            float x = CCRandom.Next() * 50;
            float y = CCRandom.Next() * 50;

            menu.Position = menu.Position + new CCPoint(x, y);
            AddChild(menu, 0, localtag);

            //[self check:self];
        }
Example #26
0
        public void PlayStackImpactSound()
        {
            if (!soundFXTurnedOff)
            {
                int randomNum = CCRandom.Next(0, 4); //0 to 4
                switch (randomNum)
                {
                case 0:
                    CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("impact1"));
                    break;

                case 1:
                    CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("impact2"));
                    break;

                case 2:
                    CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("impact3"));
                    break;

                case 3:
                    CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("impact4"));
                    break;

                case 4:
                    CCSimpleAudioEngine.SharedEngine.PlayEffect(FormatSoundFilePath("impact5"));
                    break;
                }
            }
        }
Example #27
0
        private void FruitCreated(object sender, FruitEventArgs args)
        {
            args.Fruit.PositionX = CCRandom.GetRandomFloat(0 + args.Fruit.Radius, ContentSize.Width - args.Fruit.Radius);
            args.Fruit.PositionY = ContentSize.Height + args.Fruit.Radius;
            args.Fruit.Visible   = true;

            AddChild(args.Fruit);
        }
Example #28
0
        public void SpriteInStandingState()
        {
            sprite.Texture = new CCSprite(String.Format("{0}_standing", baseImageName)).Texture;

            var blinkInterval = CCRandom.Next(3, 8);            // range 3 to 8

            Schedule(Blink, blinkInterval);
        }
Example #29
0
        void OpenEyes(float delta)
        {
            sprite.Texture = new CCSprite(String.Format("{0}", baseImageName)).Texture;
            Unschedule(OpenEyes);
            var blinkInterval = CCRandom.Next(3, 8);//   random.Next(3,8); // range 3 to 8

            Schedule(Blink, blinkInterval);
        }
Example #30
0
        void PositionMonkey()
        {
            // We start our rotation with an offset of 230,0 from the origin 0 degrees
            // and randomly position the monkey
            var startingAngle = CCRandom.GetRandomInt(-360, 360);

            monkey.Position = CCPoint.RotateByAngle(origin + new CCPoint(230, 0), origin, CCMathHelper.ToRadians(startingAngle));
            positioned      = true;
        }