public override void onEnter()
        {
            base.onEnter();

            m_emitter = CCParticleRain.node();

            m_background.addChild(m_emitter, 10);

            CCPoint p = m_emitter.position;

            m_emitter.position = new CCPoint(p.x, p.y - 100);
            m_emitter.Life     = 4;

            m_emitter.Texture = CCTextureCache.sharedTextureCache().addImage(TestResource.s_fire);

            setEmitterPosition();
        }
Exemple #2
0
        protected override void AddedToScene()
        {
            base.AddedToScene();


            // Test code --------------------------
            CCRect bounds      = VisibleBoundsWorldspace;
            var    topOfscreen = bounds.Center.Offset(0f, bounds.MaxY / 2f);
            var    rain        = new CCParticleRain(topOfscreen)
            {
                Scale = 1.5f
            };

            AddChild(rain);

            var levelKeyLabel = new CCLabel(_levelDefinition.Key, Fonts.MainFont, 48f)
            {
                Color    = CCColor3B.Black,
                Position = bounds.Center
            };

            AddChild(levelKeyLabel);

            var content = new CCLabel(_levelDefinition.Content, Fonts.MainFont, 30f)
            {
                PositionX = bounds.Center.X,
                PositionY = bounds.Center.Y - 50,
                Color     = CCColor3B.Black
            };

            AddChild(content);
            // ----------------------------------------

            var touchListener = new CCEventListenerTouchAllAtOnce {
                OnTouchesEnded = OnTouchesEnded
            };

            AddEventListener(touchListener, this);
        }
 public static new CCParticleRain Create()
 {
     var ret = new CCParticleRain();
     ret.InitWithTotalParticles(1000);
     return ret;
 }
        void HandleViewCreated(object sender, EventArgs e)
        {
            //loads the view
            var ccGView            = sender as CCGameView;
            var contentSearchPaths = new List <string>()
            {
                "Resources", "Assets"
            };

            ccGView.ContentManager.SearchPaths = contentSearchPaths;

            if (ccGView != null)
            {
                //if the view is created then load all the assets
                ccGView.DesignResolution = new CCSizeI(App.Width, App.Height);
                _scene = new CCScene(ccGView);
                _layer = new CCLayer();
                _scene.AddLayer(_layer);

                //ship
                ship           = new Ship(this);
                ship.PositionX = ((App.Width) / 2);
                ship.PositionY = ((App.Height) / 4);

                _layer.AddChild(ship);

                //starts are generated as particles
                var stars = new CCParticleRain(new CCPoint(200, App.Height))
                {
                    StartSize      = 1,
                    Color          = CCColor3B.White,
                    Speed          = 250,
                    SourcePosition = new CCPoint(0.0f, -10.0f),
                };
                stars.StartColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f);
                _layer.AddChild(stars);


                var faststars = new CCParticleRain(new CCPoint(200, App.Height))
                {
                    StartSize      = 1,
                    Speed          = 500,
                    SourcePosition = new CCPoint(0.0f, -10.0f),
                };
                faststars.StartColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f);
                _layer.AddChild(faststars);

                var slowstars = new CCParticleRain(new CCPoint(200, App.Height))
                {
                    TotalParticles = 1,
                    StartSize      = 2,
                    Color          = CCColor3B.Blue,
                    Speed          = 50,
                    SourcePosition = new CCPoint(0.0f, -10.0f),
                };
                faststars.StartColor = new CCColor4F(0.0f, 0.0f, 1.0f, 1.0f);
                _layer.AddChild(slowstars);
                //the fire trailing the rocket
                fire = new CCParticleFire(new CCPoint(((App.Width) / 2), ((App.Height) / 4)))
                {
                    StartSize      = 1,
                    Angle          = 270,
                    Speed          = 100,
                    SourcePosition = new CCPoint(0.0f, -10.0f),
                };
                _layer.AddChild(fire);
                //the handlers for the screne being touched
                var touchEvent = new CCEventListenerTouchAllAtOnce();
                touchEvent.OnTouchesEnded = OnTouchesEnded;
                _layer.AddEventListener(touchEvent);

                //asteroid
                asteroids = new List <Asteroid>();
                void HandleAsteroidCreated(Asteroid newAsteroid)
                {
                    _layer.AddChild(newAsteroid);
                    asteroids.Add(newAsteroid);
                }

                AsteroidFactory.Self.AsteroidCreated += HandleAsteroidCreated;

                //psyche

                psyche           = new Psyche();
                psyche.PositionX = 200;
                psyche.PositionY = 4000;
                psyche.VelocityY = -50;
                _layer.AddChild(psyche);
                ccGView.RunWithScene(_scene);
            }
        }