/** Adds or replaces tile with that id * * @param id the id of the {@link TiledMapTile} to add or replace. * @param tile the {@link TiledMapTile} to add or replace. */ public void putTile (int id, TiledMapTile tile) { tiles.put(id, tile); }
/** Set the plug used for a specific group. The plug will automatically be invoked. * @param plug Plug to use * @param group Group the plug is for */ public void plugIn (GroupPlug plug, int group) { plugs.put(group, plug); }
/** Adds or replaces tile with that id * * @param id the id of the {@link TiledMapTile} to add or replace. * @param tile the {@link TiledMapTile} to add or replace. */ public void putTile (int id, TiledMapTile tile) { tiles.put(id, tile); }
/** Set the plug used for a specific group. The plug will automatically be invoked. * @param plug Plug to use * @param group Group the plug is for */ public void plugIn (GroupPlug plug, int group) { plugs.put(group, plug); }
public void putAll (IntMap<? extends V> map) { for (Entry<? extends V> entry : map.entries()) put(entry.key, entry.value); }
public void putAll (IntMap<? extends V> map) { for (Entry<? extends V> entry : map.entries()) put(entry.key, entry.value); }
private static void onGamepadConnect(Gamepad gamepad) { consoleLog("onGamepadConnect: " + gamepad.getId()); gamepads.put(gamepad.getIndex(), gamepad); fireGamepadConnected(gamepad.getIndex()); }
@Override public void onGamepadConnected (int index) { Gamepad gamepad = Gamepad.getGamepad(index); GwtController controller = new GwtController(gamepad.getIndex(), gamepad.getId()); controllerMap.put(index, controller); synchronized (eventQueue) { GwtControllerEvent event = eventPool.obtain(); event.type = GwtControllerEvent.CONNECTED; event.controller = controller; eventQueue.add(event); } }
/** Constructs a Tile Set layout. The tile set image contained in the baseDir should be the original tile set images before * being processed by {@link TiledMapPacker} (the ones actually read by Tiled). * @param tileset the tile set to process * @param baseDir the directory in which the tile set image is stored */ protected TileSetLayout (int firstgid, TiledMapTileSet tileset, FileHandle baseDir) throws IOException { int tileWidth = tileset.getProperties().get("tilewidth", Integer.class); int tileHeight = tileset.getProperties().get("tileheight", Integer.class); int margin = tileset.getProperties().get("margin", Integer.class); int spacing = tileset.getProperties().get("spacing", Integer.class); this.firstgid = firstgid; image = ImageIO.read(baseDir.child(tileset.getProperties().get("imagesource", String.class)).read()); imageTilePositions = new IntMap<Vector2>(); // fill the tile regions int x, y, tile = 0; numRows = 0; numCols = 0; int stopWidth = image.getWidth() - tileWidth; int stopHeight = image.getHeight() - tileHeight; for (y = margin; y <= stopHeight; y += tileHeight + spacing) { for (x = margin; x <= stopWidth; x += tileWidth + spacing) { if (y == margin) numCols++; imageTilePositions.put(tile, new Vector2(x, y)); tile++; } numRows++; } numTiles = numRows * numCols; }
/** Constructs a Tile Set layout. The tile set image contained in the baseDir should be the original tile set images before * being processed by {@link TiledMapPacker} (the ones actually read by Tiled). * @param tileset the tile set to process * @param baseDir the directory in which the tile set image is stored */ protected TileSetLayout (int firstgid, TiledMapTileSet tileset, FileHandle baseDir) throws IOException { int tileWidth = tileset.getProperties().get("tilewidth", Integer.class); int tileHeight = tileset.getProperties().get("tileheight", Integer.class); int margin = tileset.getProperties().get("margin", Integer.class); int spacing = tileset.getProperties().get("spacing", Integer.class); this.firstgid = firstgid; image = ImageIO.read(baseDir.child(tileset.getProperties().get("imagesource", String.class)).read()); imageTilePositions = new IntMap<Vector2>(); // fill the tile regions int x, y, tile = 0; numRows = 0; numCols = 0; int stopWidth = image.getWidth() - tileWidth; int stopHeight = image.getHeight() - tileHeight; for (y = margin; y <= stopHeight; y += tileHeight + spacing) { for (x = margin; x <= stopWidth; x += tileWidth + spacing) { if (y == margin) numCols++; imageTilePositions.put(tile, new Vector2(x, y)); tile++; } numRows++; } numTiles = numRows * numCols; }
protected void addController(int deviceId, boolean sendEvent) { InputDevice device = InputDevice.getDevice(deviceId); if(!isController(device)) return; String name = device.getName(); AndroidController controller = new AndroidController(deviceId, name); controllerMap.put(deviceId, controller); if(sendEvent) { synchronized(eventQueue) { AndroidControllerEvent event = eventPool.obtain(); event.type = AndroidControllerEvent.CONNECTED; event.controller = controller; eventQueue.add(event); } } else { controllers.add(controller); } Gdx.app.log(TAG, "added controller '" + name + "'"); }
int obtainSource (boolean isMusic) { if (noDevice) return 0; for (int i = 0, n = idleSources.size; i < n; i++) { int sourceId = idleSources.get(i); int state = alGetSourcei(sourceId, AL_SOURCE_STATE); if (state != AL_PLAYING && state != AL_PAUSED) { if (isMusic) { idleSources.removeIndex(i); } else { if (sourceToSoundId.containsKey(sourceId)) { long soundId = sourceToSoundId.get(sourceId); sourceToSoundId.remove(sourceId); soundIdToSource.remove(soundId); } long soundId = nextSoundId++; sourceToSoundId.put(sourceId, soundId); soundIdToSource.put(soundId, sourceId); } alSourceStop(sourceId); alSourcei(sourceId, AL_BUFFER, 0); AL10.alSourcef(sourceId, AL10.AL_GAIN, 1); AL10.alSourcef(sourceId, AL10.AL_PITCH, 1); AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f); return sourceId; } } return -1; }
int obtainSource (boolean isMusic) { if (noDevice) return 0; for (int i = 0, n = idleSources.size; i < n; i++) { int sourceId = idleSources.get(i); int state = alGetSourcei(sourceId, AL_SOURCE_STATE); if (state != AL_PLAYING && state != AL_PAUSED) { if (isMusic) { idleSources.removeIndex(i); } else { if (sourceToSoundId.containsKey(sourceId)) { long soundId = sourceToSoundId.get(sourceId); sourceToSoundId.remove(sourceId); soundIdToSource.remove(soundId); } long soundId = nextSoundId++; sourceToSoundId.put(sourceId, soundId); soundIdToSource.put(soundId, sourceId); } alSourceStop(sourceId); alSourcei(sourceId, AL_BUFFER, 0); AL10.alSourcef(sourceId, AL10.AL_GAIN, 1); AL10.alSourcef(sourceId, AL10.AL_PITCH, 1); AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f); return sourceId; } } return -1; }
int obtainSource (boolean isMusic) { if (noDevice) return 0; for (int i = 0, n = idleSources.size; i < n; i++) { int sourceId = idleSources.get(i); int state = alGetSourcei(sourceId, AL_SOURCE_STATE); if (state != AL_PLAYING && state != AL_PAUSED) { if (isMusic) { idleSources.removeIndex(i); } else { if (sourceToSoundId.containsKey(sourceId)) { long soundId = sourceToSoundId.get(sourceId); sourceToSoundId.remove(sourceId); soundIdToSource.remove(soundId); } long soundId = nextSoundId++; sourceToSoundId.put(sourceId, soundId); soundIdToSource.put(soundId, sourceId); } alSourceStop(sourceId); alSourcei(sourceId, AL_BUFFER, 0); AL10.alSourcef(sourceId, AL10.AL_GAIN, 1); AL10.alSourcef(sourceId, AL10.AL_PITCH, 1); AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f); return sourceId; } } return -1; }
int obtainSource (boolean isMusic) { if (noDevice) return 0; for (int i = 0, n = idleSources.size; i < n; i++) { int sourceId = idleSources.get(i); int state = alGetSourcei(sourceId, AL_SOURCE_STATE); if (state != AL_PLAYING && state != AL_PAUSED) { if (isMusic) { idleSources.removeIndex(i); } else { if (sourceToSoundId.containsKey(sourceId)) { long soundId = sourceToSoundId.get(sourceId); sourceToSoundId.remove(sourceId); soundIdToSource.remove(soundId); } long soundId = nextSoundId++; sourceToSoundId.put(sourceId, soundId); soundIdToSource.put(soundId, sourceId); } alSourceStop(sourceId); alSourcei(sourceId, AL_BUFFER, 0); AL10.alSourcef(sourceId, AL10.AL_GAIN, 1); AL10.alSourcef(sourceId, AL10.AL_PITCH, 1); AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f); return sourceId; } } return -1; }
int real = touch.getIdentifier(); int touchId; touchMap.put(real, touchId = getAvailablePointer()); touched[touchId] = true; touchX[touchId] = getRelativeX(touch, canvas);
int real = touch.getIdentifier(); int touchId; touchMap.put(real, touchId = getAvailablePointer()); touched[touchId] = true; touchX[touchId] = getRelativeX(touch, canvas);
/** Registers a provider for the specified message code. * @param msg the message code * @param provider the provider to add */ public void addProvider (TelegramProvider provider, int msg) { Array<TelegramProvider> providers = msgProviders.get(msg); if (providers == null) { // Associate an empty unordered array with the message code providers = new Array<TelegramProvider>(false, 16); msgProviders.put(msg, providers); } providers.add(provider); }
/** Registers a listener for the specified message code. Messages without an explicit receiver are broadcasted to all its * registered listeners. * @param listener the listener to add * @param msg the message code */ public void addListener (Telegraph listener, int msg) { Array<Telegraph> listeners = msgListeners.get(msg); if (listeners == null) { // Associate an empty unordered array with the message code listeners = new Array<Telegraph>(false, 16); msgListeners.put(msg, listeners); } listeners.add(listener); // Dispatch messages from registered providers Array<TelegramProvider> providers = msgProviders.get(msg); if (providers != null) { for (int i = 0, n = providers.size; i < n; i++) { TelegramProvider provider = providers.get(i); Object info = provider.provideMessageInfo(msg, listener); if (info != null) { Telegraph sender = ClassReflection.isInstance(Telegraph.class, provider) ? (Telegraph)provider : null; dispatchMessage(0, sender, listener, msg, info, false); } } } }
private IntMap<IntArray> getDefault(){ IntMap<IntArray> keyboard = new IntMap<IntArray>(); keyboard.put(InputAction.PRESS_LEFT, new IntArray(new int[] { Input.Keys.LEFT })); keyboard.put(InputAction.PRESS_RIGHT, new IntArray(new int[] { Input.Keys.RIGHT })); keyboard.put(InputAction.PRESS_UP, new IntArray(new int[] { Input.Keys.UP })); keyboard.put(InputAction.PRESS_DOWN, new IntArray(new int[] { Input.Keys.DOWN })); return keyboard; } }