Skip to content

codepoke/util-xtend-gdx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

util-xtend-gdx

General Xtend code which can be used for LibGDX & Artemis, such as Active Annotations, extension methods and general utility code.

ActiveAnnotations

ExtensionDSLFactory

The ExtensionDSLFactory is an Active Annotation which creates extension methods that unwrap and delegate the constructors of the targeted value, apply the created instance on given code, and then return it.

In summary, with a single annotation you can generate DSL instead of having to handroll your own. This annotation generates the mundane parts of DSLs which normally need to be handwritten and are 80% of the DSL, such as Kotlin's Anko.

An example use case, as provided by the EntityDSLFactory:

def static character(Entity target, int health, int momentum) {
	target => [
		defence(0, 10)
		health(health)
		momentum(momentum, 40)
		spineAnimation(SkeletonData, "porcupine.json") => [
			defaultKey = "stance_idle#0"
			skin = "Brute"
			scale = 2
		]
	]
}

or when used to create a DSL for Table and Scene2D:

 table[
        label("Please select one of the following:", skin)

        table[
            textButton("Cancel", skin)
            textButton("OK", skin)
        ]
    ]

Mappers

Mappers is an ActiveAnnotation which can be used with the Artemis framework to generate the ComponentMappers for given targets, and create extension methods which allow components to be accessed in a variable-access like syntax.

// Given an Entity entity, and a Component type HealthComponent; this allows syntax such as:
val health = entity.health

// As opposed to:
val health = ComponentMapper.get(entity) // or
val health = entity.getComponent(HealthComponent.class)

About

Active Annotations which can be used for LibGDX & Artemis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published