Exemplo n.º 1
0
        // Constructor
        public GamePage()
        {
            InitializeComponent();

            _game = XamlGame <MultipleObjectsGame> .Create("", this);

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }
        //-------------------------------------------------------------------------------------
        // Class constructors

        internal BallObject(MultipleObjectsGame 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);
        }