コード例 #1
0
ファイル: IntroLayer.cs プロジェクト: wfw/cocos-sharp-samples
        public void createGameScreen()
        {
            CCSprite bg = new CCSprite("bg.png");

            bg.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.5f);
            AddChild(bg, kBackground);

            _lineContainer = LineContainer.Create();
            AddChild(_lineContainer);


            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("sprite_sheet.plist");
            _gameBatchNode = new CCSpriteBatchNode("sprite_sheet.png", 100);

            AddChild(_gameBatchNode, kForeground);

            _rocket          = Rocket.Create();
            _rocket.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.1f);
            _gameBatchNode.AddChild(_rocket, kForeground, kSpriteRocket);

            //add planets
            GameSprite planet;

            _planets = new List <GameSprite>();
            // _planets->retain();

            planet          = new GameSprite("planet_1.png");
            planet.Position = new CCPoint(_screenSize.Width * 0.25f,
                                          _screenSize.Height * 0.8f);

            _gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
            _planets.Add(planet);

            planet          = new GameSprite("planet_2.png");
            planet.Position = new CCPoint(_screenSize.Width * 0.8f,
                                          _screenSize.Height * 0.45f);
            _gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
            _planets.Add(planet);

            planet          = new GameSprite("planet_3.png");
            planet.Position = new CCPoint(_screenSize.Width * 0.75f,
                                          _screenSize.Height * 0.8f);
            _gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
            _planets.Add(planet);

            planet          = new GameSprite("planet_4.png");
            planet.Position = new CCPoint(_screenSize.Width * 0.5f,
                                          _screenSize.Height * 0.5f);
            _gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
            _planets.Add(planet);

            planet          = new GameSprite("planet_5.png");
            planet.Position = new CCPoint(_screenSize.Width * 0.18f,
                                          _screenSize.Height * 0.45f);
            _gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
            _planets.Add(planet);

            planet          = new GameSprite("planet_6.png");
            planet.Position = new CCPoint(_screenSize.Width * 0.8f,
                                          _screenSize.Height * 0.15f);
            _gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
            _planets.Add(planet);

            planet          = new GameSprite("planet_7.png");
            planet.Position = new CCPoint(_screenSize.Width * 0.18f,
                                          _screenSize.Height * 0.1f);
            _gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
            _planets.Add(planet);

            CCSprite scoreLabel = new GameSprite("label_score.png");

            scoreLabel.Position = new CCPoint(_screenSize.Width * 0.4f, _screenSize.Height * 0.95f);
            _gameBatchNode.AddChild(scoreLabel, kBackground);

            _scoreDisplay = new CCLabelTtf("0", "MarkerFelt", 22);

            _scoreDisplay.AnchorPoint = new CCPoint(0, 0.5f);
            _scoreDisplay.Position    = new CCPoint(_screenSize.Width * 0.48f, _screenSize.Height * 0.95f);
            AddChild(_scoreDisplay, kBackground);

            _pauseBtn          = new GameSprite("btn_pause_off.png");
            _pauseBtn.Visible  = false;
            _pauseBtn.Position = new CCPoint(_screenSize.Width * 0.06f, _screenSize.Height * 0.95f);
            _gameBatchNode.AddChild(_pauseBtn, kBackground);


            _intro          = new GameSprite("logo.png");
            _intro.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
            CCSprite play = new CCSprite("label_play.png");

            play.Position = new CCPoint(_intro.BoundingBox.Size.Width * 0.5f, -_intro.BoundingBox.Size.Height * 0.5f);
            _intro.AddChild(play);
            _gameBatchNode.AddChild(_intro, kForeground);

            _gameOver          = new GameSprite("gameOver.png");
            _gameOver.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
            _gameOver.Visible  = false;
            _gameBatchNode.AddChild(_gameOver, kForeground);

            _paused          = new GameSprite("label_paused.png");
            _paused.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
            _paused.Visible  = false;
            _gameBatchNode.AddChild(_paused, kForeground);
        }
コード例 #2
0
		public void createGameScreen()
		{

			CCSprite bg = new CCSprite("bg.png");
			bg.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.5f);
			AddChild(bg, kBackground);

			_lineContainer = LineContainer.Create();
			AddChild(_lineContainer);


			CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("sprite_sheet.plist");
			_gameBatchNode = new CCSpriteBatchNode("sprite_sheet.png", 100);

			AddChild(_gameBatchNode, kForeground);

			_rocket = Rocket.Create();
			_rocket.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.1f);
			_gameBatchNode.AddChild(_rocket, kForeground, kSpriteRocket);

			//add planets
			GameSprite planet;
			_planets = new List<GameSprite>();
			// _planets->retain();

			planet = new GameSprite("planet_1.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.25f,
									_screenSize.Height * 0.8f);

			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_2.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.8f,
									_screenSize.Height * 0.45f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_3.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.75f,
									_screenSize.Height * 0.8f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_4.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.5f,
									_screenSize.Height * 0.5f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_5.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.18f,
									_screenSize.Height * 0.45f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_6.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.8f,
									_screenSize.Height * 0.15f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			planet = new GameSprite("planet_7.png");
			planet.Position = new CCPoint(_screenSize.Width * 0.18f,
									_screenSize.Height * 0.1f);
			_gameBatchNode.AddChild(planet, kBackground, kSpritePlanet);
			_planets.Add(planet);

			CCSprite scoreLabel = new GameSprite("label_score.png");
			scoreLabel.Position = new CCPoint(_screenSize.Width * 0.4f, _screenSize.Height * 0.95f);
			_gameBatchNode.AddChild(scoreLabel, kBackground);

			_scoreDisplay = new CCLabelTtf("0", "MarkerFelt", 22);

			_scoreDisplay.AnchorPoint = new CCPoint(0, 0.5f);
			_scoreDisplay.Position = new CCPoint(_screenSize.Width * 0.48f, _screenSize.Height * 0.95f);
			AddChild(_scoreDisplay, kBackground);

			_pauseBtn = new GameSprite("btn_pause_off.png");
			_pauseBtn.Visible = false;
			_pauseBtn.Position = new CCPoint(_screenSize.Width * 0.06f, _screenSize.Height * 0.95f);
			_gameBatchNode.AddChild(_pauseBtn, kBackground);


			_intro = new GameSprite("logo.png");
			_intro.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
			CCSprite play = new CCSprite("label_play.png");
			play.Position = new CCPoint(_intro.BoundingBox.Size.Width * 0.5f, -_intro.BoundingBox.Size.Height * 0.5f);
			_intro.AddChild(play);
			_gameBatchNode.AddChild(_intro, kForeground);

			_gameOver = new GameSprite("gameOver.png");
			_gameOver.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
			_gameOver.Visible = false;
			_gameBatchNode.AddChild(_gameOver, kForeground);

			_paused = new GameSprite("label_paused.png");
			_paused.Position = new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.55f);
			_paused.Visible = false;
			_gameBatchNode.AddChild(_paused, kForeground);

		}