https://github.com/junkdog/kbdluv
Easy shortcuts for libgdx/artemis.
https://github.com/junkdog/kbdluv
artemis-odb libgdx shortcuts
Last synced: 11 months ago
JSON representation
Easy shortcuts for libgdx/artemis.
- Host: GitHub
- URL: https://github.com/junkdog/kbdluv
- Owner: junkdog
- Created: 2016-03-05T21:00:43.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-28T00:30:40.000Z (almost 10 years ago)
- Last Synced: 2025-09-01T06:56:17.950Z (11 months ago)
- Topics: artemis-odb, libgdx, shortcuts
- Language: Java
- Homepage:
- Size: 31.3 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
## kbdluv-artemis
Easy shortcuts for libgdx/artemis.
#### Usage
- Extend ShortcutProcessor
- Implement `getEntity()`
- `getEntity` can return null if no shortcut methods take an Entity
or Component parameter
- Create a method, annotate it with `@Shortcut`. Method can take 4 forms:
1. `zeroArguments()`
1. `withEntity(Entity e)` (see getEntity())
1. `withEntityAndComponent(Entity e, Position posiiton)`
1. `withComponent(Position posiiton)`
- Register the input processor as you normally would.
## Getting Started
#### Maven
```xml
net.onedaybeard.kbdluv
kbdluv-artemis
0.2.3
```
#### Gradle
```groovy
dependencies { compile "net.onedaybeard.artemis:kbdluv-artemis:0.2.3" }
```
#### Example
Method parameters for shortcuts are guaranteed to never be null.
If any parameter can't be inferred, the shortcut method is not
invoked.
```java
// makes for shorter @Shorcut:s.
import static com.badlogic.gdx.Input.Keys.*;
public class MyShortcuts extends ShortcutProcessor {
// shortcut processors are auto-wiring
private ComonentMapper positionMapper;
private TagManager tagManager;
public MyShortcuts(World world) {
super(world);
}
/**
* The entity returned by this method is passed to shortcuts which
* require an {@link Entity} - see below.
*/
@Override
protected Entity getEntity() {
// how entities are resolved is up to you is up to you
return world.getSystem(FooBarEntityTrackerSystem.class).getHoveredEntity();
}
// 'A' - note "import static com.badlogic.gdx.Input.Keys.*;"
@Shortcut(A)
private void shortcutWithNoParameters() {
// ...
}
// MOD_ fields live in ShortcutProcessor
@Shortcut(MOD_SHIFT | B) // left and right modifier keys are treated equally
private void doSomethingWith(Entity e) {
// ...
}
@Shortcut(MOD_CTRL | MOD_SHIFT | C) // combine multiple modifier keys
private void entityAndComponent(Entity owner, ComponentA componentOfOwner) {
// ...
}
@Shortcut(MOD_ALT | D) // same as above, but omits the Entity
private void justTheComponent(ComponentA comp) {
// ...
}
}
```