-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Composure can be installed via haxelib using the commandline:
haxelib install composure-hx
Class inheritance is massively overused by developers, and by replacing it with a solid composition design, a lot of code becomes a lot more reusable.
Some languages and platforms have native support for composition (e.g. Unity3D), but for AS3/Haxe there was nothing, so about two years ago I built a lightweight composition framework for AS3 called Composure, I’ve recently completely rebuilt it for Haxe, utilising Haxe’s awesome typing and macro systems to make this small library really powerful.
Those familiar with Unity3D will be familiar with GameObjects and Components, the two core building blocks used to build things. In Composure these two core types are known as ComposeGroups and Traits.
Each conceptual item in your game/app will be a ComposeGroup, with a bunch of Traits attached to it. Any time while your app is running these traits can be added/remove, changing the behaviour of on object completely. Say, for example, you have a player’s character on-screen and wish to switch from the user controlling the character to computer control, you would simply remove your MouseKeyboardControllerTrait and replace it with a ComputerControllerTrait.
These ComposeGroups must be added to the ComposeRoot object to be active, and can also be parented to other ComposeGroup objects (forming a heirarchy).
Basics
More
- Manually adding Injectors
- [Coupling Display Hierarchies and Composure (Using EaselJS example)](http://github.com/TomByrne/composure/wiki/Coupling-Display-Hierarchies-and-Composure-(Using-EaselJS-example\))
- Macro under-the-hood & Proxy Traits