private void SetSelection(ButtonSprite selection) { if (null != selection && m_timerSelection < DateTime.Now) { m_timerSelection = DateTime.Now + TimeSpan.FromMilliseconds(DELAY_MS); SelectedButton = selection; } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here _font = Content.Load<SpriteFont>("spriteFont1"); _soundPool = new SoundPool(5, Stream.Music, 0); AssetFileDescriptor assetFileDescriptor; assetFileDescriptor = Activity.ApplicationContext.Assets.OpenFd("Content/boom.wav"); _soundBoom = _soundPool.Load(assetFileDescriptor, 1); assetFileDescriptor = Activity.ApplicationContext.Assets.OpenFd("Content/ouch.wav"); _soundOuch = _soundPool.Load(assetFileDescriptor, 1); _btnBoom = new ButtonSprite(); _btnBoom.Initialize(_font, Content.Load<Texture2D>("Graphics\\ButtonActive"), Content.Load<Texture2D>("Graphics\\ButtonInactive")); _btnBoom.Position = new Vector2(150, 200); _btnBoom.TextureScale = new Vector2(2f, 0.5f); _btnBoom.Text = "Boom"; _btnBoom.TextOffset = new Vector2(40, 20); _buttons.Add(_btnBoom); _btnOuch = new ButtonSprite(); _btnOuch.Initialize(_font, Content.Load<Texture2D>("Graphics\\ButtonActive"), Content.Load<Texture2D>("Graphics\\ButtonInactive")); _btnOuch.Position = new Vector2(600, 200); _btnOuch.TextureScale = new Vector2(2f, 0.5f); _btnOuch.Text = "Ouch"; _btnOuch.TextOffset = new Vector2(40, 20); _buttons.Add(_btnOuch); _focusManager.SelectedButton = _btnBoom; _focusManager.Mappings[_btnBoom] = new FocusManager.ButtonMapping() { Right = _btnOuch }; _focusManager.Mappings[_btnOuch] = new FocusManager.ButtonMapping() { Left = _btnBoom, }; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here _font = Content.Load <SpriteFont>("spriteFont1"); _soundPool = new SoundPool(5, Stream.Music, 0); AssetFileDescriptor assetFileDescriptor; assetFileDescriptor = Activity.ApplicationContext.Assets.OpenFd("Content/boom.wav"); _soundBoom = _soundPool.Load(assetFileDescriptor, 1); assetFileDescriptor = Activity.ApplicationContext.Assets.OpenFd("Content/ouch.wav"); _soundOuch = _soundPool.Load(assetFileDescriptor, 1); _btnBoom = new ButtonSprite(); _btnBoom.Initialize(_font, Content.Load <Texture2D>("Graphics\\ButtonActive"), Content.Load <Texture2D>("Graphics\\ButtonInactive")); _btnBoom.Position = new Vector2(150, 200); _btnBoom.TextureScale = new Vector2(2f, 0.5f); _btnBoom.Text = "Boom"; _btnBoom.TextOffset = new Vector2(40, 20); _buttons.Add(_btnBoom); _btnOuch = new ButtonSprite(); _btnOuch.Initialize(_font, Content.Load <Texture2D>("Graphics\\ButtonActive"), Content.Load <Texture2D>("Graphics\\ButtonInactive")); _btnOuch.Position = new Vector2(600, 200); _btnOuch.TextureScale = new Vector2(2f, 0.5f); _btnOuch.Text = "Ouch"; _btnOuch.TextOffset = new Vector2(40, 20); _buttons.Add(_btnOuch); _focusManager.SelectedButton = _btnBoom; _focusManager.Mappings[_btnBoom] = new FocusManager.ButtonMapping() { Right = _btnOuch }; _focusManager.Mappings[_btnOuch] = new FocusManager.ButtonMapping() { Left = _btnBoom, }; }