当前位置: 首页>>代码示例>>C#>>正文


C# Layer.AddChild方法代码示例

本文整理汇总了C#中Layer.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# Layer.AddChild方法的具体用法?C# Layer.AddChild怎么用?C# Layer.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Layer的用法示例。


在下文中一共展示了Layer.AddChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EndScene

        public EndScene()
        {
            _waitTimer = new Timer();
            ScheduleUpdate();
            _sceneCamera = (Camera2D)Camera;
            Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f);
            _sceneCamera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f);

            _groundLayer = new Layer(_sceneCamera);

            Animations = new Dictionary<string, Animation>();
            var texInfo = new TextureInfo(AssetManager.GetTexture("catanimation"), new Vector2i(5,1),TRS.Quad0_1);
            _currentAnimation = new Animation(0, 5, 0.1f, false);
            _currentAnimation.Play();

            _cat = new SpriteTile(texInfo);
            _cat.TileIndex1D = _currentAnimation.CurrentFrame;
            _cat.Quad.S = new Vector2(258, 214);
            _cat.CenterSprite();
            _cat.Position = new Vector2(_sceneCamera.CalcBounds().Point00.X, _sceneCamera.CalcBounds().Point00.Y + _cat.TextureInfo.TextureSizef.Y/2 +64 );

            var background = new SpriteTile(new TextureInfo(AssetManager.GetTexture("background_paper")));
            background.Quad.S = background.TextureInfo.TextureSizef;
            background.CenterSprite();
            background.Position = _sceneCamera.CalcBounds().Center;

            for(var i = 0; i < 5; i++)
            {
                var _sprite = new GroundTile(new TextureInfo(AssetManager.GetTexture("ground_tile")));
                _groundLayer.AddChild(_sprite);
                _sprite.Quad.S = _sprite.TextureInfo.TextureSizef;
                _sprite.Position = new Vector2(_sceneCamera.CalcBounds().Point00.X + i * _sprite.TextureInfo.TextureSizef.X, _sceneCamera.CalcBounds().Point00.Y - _sprite.TextureInfo.TextureSizef.Y / 2);
            }
            _musicPlayer = AssetManager.GetBGM("endscreen").CreatePlayer();
            _musicPlayer.Play();
            AddChild(background);
            AddChild (_cat);
            AddChild (_groundLayer);
        }
开发者ID:edibletoaster,项目名称:PSM-Game,代码行数:39,代码来源:EndScene.cs

示例2: LevelSelectScreen


//.........这里部分代码省略.........
            //					CubeText = "99",
            //					ScoreText = "88"
            //				}
            //			};
            //			for( int i=0; i < Solutions.Count; i++) {
            //				Solutions[i].Visible = false;
            //				var column = i % 4;
            //				var row = ( i - column ) / 4;
            //				Solutions[i].Position = new Vector2(Director.Instance.GL.Context.Screen.Width - 339.0f + 60.0f * column,
            //				                                    Director.Instance.GL.Context.Screen.Height - 200.0f - row * 80.0f);
            //				this.AddChild(Solutions[i]);
            //			}

            QualitiesText = new Label() {
                Text = "qualities",
                Position = new Vector2(623.0f, 223.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ),
                Color = LevelManager.Instance.BackgroundColor
            };

            //			CompletionPercentageText = new Label() {
            //				Text = (1.0f).ToString("P0"),
            //				Position = new Vector2(638.0f, 150.0f),
            //				FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ),
            ////				Color = new Vector4( 0.16078431f, 0.88627451f, 0.88627451f, 1.0f)
            //			};
            //			CenterText(CompletionPercentageText);
            //			this.AddChild(CompletionPercentageText);

            Icons = new Node[4];
            IconLabels = new Label[4];
            for( int i=0; i < Icons.Length; i++) {
                Icons[i] = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2);
                Icons[i].Position = new Vector2(623.0f + 68.0f * (float)i, 2.0f * BUTTON_HEIGHT + 20.0f);
            //				Icons[i].Scale = new Vector2(0.25f, 0.25f);
                IconLabels[i] = new Label() {
                    FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Bold") ),
                    Color = LevelManager.Instance.BackgroundColor
                };
            }

            LevelSelectTitleText = new Label(){
                Text="level select",
                Position = new Vector2(50.0f, 488.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Regular") ),
                Color = Support.ExtractColor("333330")
            };

            LevelSelectInstructionsText = new Label(){
                Text="select a cube and then press play.",
                Position = new Vector2(50.0f, 465.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Regular") ),
                Color = Support.ExtractColor("333330")
            };

            BackButton = new BetterButton(361.0f, BUTTON_HEIGHT) {
                Text = "back",
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, BUTTON_HEIGHT)
            };
            BackButton.background.RegisterPalette(2);

            PlayButton = new BetterButton(361.0f, BUTTON_HEIGHT) {
                Text = "play",
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f)
            };
            PlayButton.background.RegisterPalette(1);

            // SWIPE LAYER
            this.AddChild(this.SwipePanels);
            foreach( LevelPage panel in Panels) {
                this.AddChild(panel);
            }
            (Panels[0] as LevelPage).Items[0].AddChild(Indicator);

            // UI LAYERS
            BackLayer = new Layer();
            this.AddChild(BackLayer);
            FrontLayer = new Layer();
            this.AddChild(FrontLayer);

            // BACK LAYER ELEMENTS
            BackLayer.AddChild(BlackBlock1);
            BackLayer.AddChild(BlackBlock2);
            BackLayer.AddChild(Solutions);

            // FRONT LAYER ELEMENTS
            FrontLayer.AddChild(BlackBlock3);
            FrontLayer.AddChild(BlackBlock4);

            FrontLayer.AddChild(LevelNumberText);
            FrontLayer.AddChild(PossibleSolutionsText);
            FrontLayer.AddChild(QualitiesText);
            for( int i=0; i < Icons.Length; i++) {
                FrontLayer.AddChild(Icons[i]);
            }
            FrontLayer.AddChild(LevelSelectTitleText);
            FrontLayer.AddChild(LevelSelectInstructionsText);
            FrontLayer.AddChild(BackButton);
            FrontLayer.AddChild(PlayButton);
        }
开发者ID:phoenixperry,项目名称:crystallography,代码行数:101,代码来源:LevelSelectScreen.cs

示例3: Game

        public Game()
        {
            Started = false;
            Running = false;

            // Setup Window
            Bounds = new FloatRect(0, 0, ResolutionDefault.X, ResolutionDefault.Y);
            WindowSettings = new ContextSettings();
            WindowSettings.AntialiasingLevel = 6;
            CreateWindow();

            // Black Bars (for fullscreen)
            Layer_BlackBars = new Layer();
            RectangleShape BlackBarLeft = new RectangleShape(new Vector2f(2000, 5000));
            BlackBarLeft.Position = new Vector2f(-BlackBarLeft.Size.X, 0);
            BlackBarLeft.FillColor = new Color(0, 0, 0);
            Layer_BlackBars.AddChild(BlackBarLeft);
            RectangleShape BlackBarRight = new RectangleShape(new Vector2f(2000, 5000));
            BlackBarRight.Position = new Vector2f(Size.X, 0);
            BlackBarRight.FillColor = new Color(0, 0, 0);
            Layer_BlackBars.AddChild(BlackBarRight);

            // Setup
            Layer_Background = new Layer();
            Layer_Other = new Layer();
            Layer_Objects = new Layer();
            Layer_OtherAbove = new Layer();
            Layer_GUI = new Layer();

            // Start Menu
            StartMenu = new StartMenu(this);
            Layer_GUI.AddChild(StartMenu);

            Music = new Music("assets/audio/music/Speed Pirate - LuigiSounds.ogg");
            Music.Loop = true;
            Music.Play();

            // Game Loop
            Stopwatch clock = new Stopwatch();
            clock.Start();
            while (Window.IsOpen())
            {
                // Process events
                Window.DispatchEvents();

                if (clock.Elapsed.TotalSeconds >= (1.0f / FPS))
                {
                    if (CloseNextUpdate)
                    {
                        Window.Close();
                        return;
                    }

                    // Clear screen
                    Window.Clear();

                    // Update Game
                    Update((float)clock.Elapsed.TotalSeconds);
                    clock.Restart();

                    // Draw Game
                    Draw();

                    // Update the window
                    Window.Display();
                }
            }
        }
开发者ID:Torrunt,项目名称:SingleSwitchGame,代码行数:68,代码来源:Game.cs

示例4: Game

        public Game()
        {
            //			Director.Instance.DebugFlags |= DebugFlags.Navigate; // press left alt + mouse to navigate in 2d space
            //			Director.Instance.DebugFlags |= DebugFlags.DrawGrid;
            Director.Instance.DebugFlags |= DebugFlags.DrawContentWorldBounds;
            Director.Instance.DebugFlags |= DebugFlags.DrawContentLocalBounds;
            //			Director.Instance.DebugFlags |= DebugFlags.DrawTransform;
            //			Director.Instance.DebugFlags |= DebugFlags.DrawPivot;

            DebugString = new DebugString(Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context);
            Scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            Background = new Layer();
            World = new Layer();
            EffectsLayer = new Layer();
            Foreground = new Layer();
            Curtains = new Layer();
            Interface = new Layer();
            Random = new Random();
            Collider = new EntityCollider();
            ParticleEffects = new Support.ParticleEffectsManager();
            TextureTileMaps = new Support.TextureTileMapManager();
            UI = new UI();
            ScoreManager = new ScoreManager();

            SpriteBatch = new SpriteBatch();

            BuildTextureTileMaps();

            AddQueue = new List<GameEntity>();
            RemoveQueue = new List<GameEntity>();

            Scene.AddChild(Background);
            Scene.AddChild(World);
            Scene.AddChild(EffectsLayer);
            Scene.AddChild(Foreground);
            Scene.AddChild(Interface);
            Scene.AddChild(Curtains);

            Scene.Camera.SetViewFromViewport();

            // temporary: munge viewport to match vita + assets
            Vector2 ideal_screen_size = ScreenSize;
            Camera2D camera = Scene.Camera as Camera2D;
            camera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f);
            TitleCameraCenter = camera.Center;
            CameraTarget = TitleCameraCenter;

            if(ParticleEffects!=null)
                EffectsLayer.AddChild(ParticleEffects);
            Interface.AddChild(UI);

            // world
            var bg_forest = Support.SpriteFromFile("/Application/assets/background_test2.png");
            bg_forest.Scale *= 1;

            bg_forest.Position = new Vector2(0f, 0.0f);

            Background.AddChild(bg_forest);

            UI.TitleMode();

            Sce.PlayStation.HighLevel.GameEngine2D.Scheduler.Instance.Schedule(Scene, TickTitle, 0.0f, false);

            World.AdHocDraw += this.DrawWorld;
        }
开发者ID:nyakagawan,项目名称:PSM-kabuto,代码行数:65,代码来源:Game.cs

示例5: GamePlayScene

        public GamePlayScene()
        {
            this.ScheduleUpdate ();
            _garnishTimer = new Timer();
            _groundTimer = new Timer();
            _waterLevel = 272;
            _groundLevel = 120;
            _random = new Random();
            _garnishDelay = _random.Next(0,5);

            Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f);
            SceneCamera = (Camera2D)Camera;

            SceneCamera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f);

            _groundGarnish = new Layer(SceneCamera);
            _mainLayer = new Layer(SceneCamera);
            _playerCreature = new PlayerCreature ();
            _playerCreature.sprite.Position = Camera.CalcBounds ().Center;
            _mainLayer.AddChild (_playerCreature.sprite);

            _backgroundLayer = new Layer(SceneCamera, 0, 0);
            var background = new SpriteTile(new TextureInfo(AssetManager.GetTexture("background_paper")));
            _backgroundLayer.AddChild(background);
            background.Quad.S = background.TextureInfo.TextureSizef;
            background.CenterSprite();
            background.Position = SceneCamera.CalcBounds().Center;

            _water = new SpriteTile(new TextureInfo(AssetManager.GetTexture("water")));
            _water.Quad.S = _water.TextureInfo.TextureSizef;
            _water.CenterSprite();
            _water.Position = SceneCamera.CalcBounds().Center + new Vector2(0, -244);

             _waterTop = new WaterTile(new TextureInfo(AssetManager.GetTexture("waveline")));
            _waterTop.Quad.S = _waterTop.TextureInfo.TextureSizef;
            _waterTop.CenterSprite();
            _waterTop.Position = _water.Position + new Vector2(0 ,_water.TextureInfo.TextureSizef.Y /2 );
            _waterTop.Position = SceneCamera.CalcBounds().Center + new Vector2(0, -244 + _water.TextureInfo.TextureSizef.Y/2f);

            _groundLayer = new Layer(SceneCamera, 1, 1);
            _groundGarnish = new Layer(SceneCamera, 1, 1);

            var texInfo = new TextureInfo(AssetManager.GetTexture ("ground_tile"));
            _ground = new SpriteList(texInfo);
            _sprite = new SpriteTile(texInfo);
            _ground.AddChild(_sprite);
            _sprite.Quad.S = texInfo.TextureSizef;
            _sprite.CenterSprite();
            _sprite.TileIndex2D = new Vector2i(0,0);

            GenerateMap();

            _enemies = new List<Enemy>();
            _bullets = new List<Bullet>();
            /*
            // enemy sprite test code
            var fish0 = new FishEnemy (new Vector2 (30.0f, 30.0f), _playerCreature);
            var fish1 = new FishEnemy (new Vector2 (15.0f, 15.0f), _playerCreature);
            var fish2 = new FishEnemy (new Vector2 (100.0f, 70.0f), _playerCreature);

            _enemies.Add (fish0);
            _enemies.Add (fish1);
            _enemies.Add (fish2);
            */
            var dummyFish = new FishEnemy (new Vector2 (-25.0f, -25.0f), _playerCreature);
            dummyFish.sprite.UnscheduleAll();
            _mainLayer.AddChild (FishEnemy.spriteList);

            var dummyBullet = new Bullet(new Vector2(-25.0f,-25.0f));
            dummyBullet.sprite.UnscheduleAll();
            //dummyBullet.sprite.Visible = false;
            _mainLayer.AddChild(Bullet.spriteList);

            _waterLayer = new Layer(SceneCamera);
            _waterLayer.AddChild(_water);
            _waterLayer.AddChild(_waterTop);

            _musicPlayer = AssetManager.GetBGM("gameplaymusic").CreatePlayer();
            _musicPlayer.Loop = true;
            _musicPlayer.Play();

            AddChild (_backgroundLayer);

            AddChild (_mainLayer);
            AddChild(_groundLayer);
            AddChild(_groundGarnish);
            AddChild(_waterLayer);

            _eventManager = new EventManager(_mainLayer,_playerCreature);
        }
开发者ID:edibletoaster,项目名称:PSM-Game,代码行数:90,代码来源:GamePlayScene.cs


注:本文中的Layer.AddChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。