private void updateKeyboardInput() { var pressedKeys = Keyboard.GetState().GetPressedKeys(); for (int i = 0; i < pressedKeys.Length; i++) { if (!contains(_previousPressedKeys, pressedKeys[i])) { var monoGameKey = monoGameKeyToGdxKey(pressedKeys[i]); if (monoGameKey != 0) { _inputProcessor.keyDown(monoGameKey); var keyCharacter = monoGameKeyToChar(pressedKeys[i]); if (keyCharacter != 0) { _inputProcessor.keyTyped(keyCharacter); } } } } for (int i = 0; i < _previousPressedKeys.Length; i++) { if (!contains(pressedKeys, _previousPressedKeys[i])) { var monoGameKey = monoGameKeyToGdxKey(_previousPressedKeys[i]); if (monoGameKey != 0) { _inputProcessor.keyUp(monoGameKey); } } } _previousPressedKeys = pressedKeys; }
public MonoGameInput() { _previousMouseState = Mouse.GetState(); _previousPressedKeys = new Keys[0]; _gamePads = new MonoGameGamePad[Microsoft.Xna.Framework.Input.GamePad.MaximumGamePadCount]; for (var i = 0; i < _gamePads.Length; i++) { _gamePads[i] = new MonoGameGamePad(i); } _gamePadsArray = Array.with(_gamePads); }
//custom contains implementation because c# one is based on linq which is too slow private bool contains(Keys[] keys, Keys key) { for (int i = 0; i < keys.Length; i++) { if (keys[i] == key) { return(true); } } return(false); }
public void update() { updateControllerInput(); _previousMouseState = _currentMouseState; _previousPressedKeys = _currentPressedKeys; _currentMouseState = Mouse.GetState(); _currentPressedKeys = Keyboard.GetState().GetPressedKeys(); if (_inputProcessor != null) { updateMouseInput(); updateKeyboardInput(); } }
public Array findRegions(string str) { var images = new MonoGameTextureAtlasImage[_atlasImages[str].Count]; _atlasImages[str].Values.CopyTo(images, 0); System.Array.Sort(images); var regions = new MonoGameTextureAtlasRegion[images.Length]; for (var i = 0; i < images.Length; i++) { regions[i] = images[i].textureRegion; } return(Array.with(regions)); }
public Array getRegions() { var regions = new List <MonoGameTextureAtlasRegion>(); foreach (var imageName in _atlasImages.Values) { foreach (var image in imageName.Values) { regions.Add(image.textureRegion); } } return(Array.with(regions.ToArray())); }
public Array findRegions(string str) { Array result = new Array(); for (int i = 0; i < _atlasImages.size; i++) { TextureAtlasRegion textureAtlasRegion = _atlasImages.get(i) as TextureAtlasRegion; if (textureAtlasRegion.getName().Equals(str)) { result.add(textureAtlasRegion); } } return(result); }