コード例 #1
0
        public GamePage(string launchArguments)
        {
            this.InitializeComponent();

            // Create the game.
            _game = XamlGame <ApplicationLifeCycleGame> .Create(launchArguments, Window.Current.CoreWindow, this);
        }
コード例 #2
0
        //-------------------------------------------------------------------------------------
        // Class constructors

        internal BallObject(ApplicationLifeCycleGame game, Texture2D texture)
            : base(game, Vector2.Zero, texture)
        {
            // Store a strongly-typed reference to the game
            _game = game;

            // Set a random position
            PositionX = GameHelper.RandomNext(0, _game.GraphicsDevice.Viewport.Bounds.Width);
            PositionY = GameHelper.RandomNext(0, _game.GraphicsDevice.Viewport.Bounds.Height);

            // Set the origin
            Origin = new Vector2(texture.Width, texture.Height) / 2;

            // Set a random color
            SpriteColor = new Color(GameHelper.RandomNext(0, 256), GameHelper.RandomNext(0, 256), GameHelper.RandomNext(0, 256));

            // Set a horizontal movement speed for the box
            _xadd = GameHelper.RandomNext(-5.0f, 5.0f);
        }