An open API service indexing awesome lists of open source software.

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.

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) {
// ...
}
}

```