Skip to content
Mark Knol edited this page Jun 25, 2014 · 12 revisions
### Frequently Asked Questions

🔹 How do I _____ using Flambe?

Check out this documentation, which lists some common tasks and best practices. The code samples in the demo repository might also be helpful.

🔹 How does the entity-component system work?

An entity is an object in a game. Entities don't do anything on their own, components are attached to them to add data and logic. Entities are also hierarchical -- they can have other entities as children. This hierarchy when combined with the Sprite component, delivers the familiar Flash-like scene graph, but with the flexibility of being able to add other types of components.

Some components override each other if they have a common parent class. Adding a FillSprite to an entity for example will replace its ImageSprite. That's because they both extend Sprite. Since Sprite extends Component, anything that subclasses Sprite will share the "Sprite" namespace. Under the hood, this is implemented by giving a unique ID to each class that directly extends Component.

More details here: Flambe-core

🔹 Can I use masks?

Yes, any Sprite can be masked. It is a Rectangle and it is called a scissor:

mySprite.scissor = new Rectangle(0, 0, 100, 100); // (x,y,width,height)

🔹 Can I use irregular shaped masked

Yes, but you need to process this on a new texture (using System.renderer.createTexture). This can be heavy, but when you create this once and store the texture, it should OK in terms of performance. You could choose to dispose the original texture if you don't need that one anymore. This is a helper function for masking textures:

public static function getMaskedTexture(image:Texture, mask:Texture, destX:Float = 0, destY:Float = 0):Texture
{
	var texture:Texture = System.renderer.createTexture(image.width, image.height);	
	var graphics = texture.graphics;
	graphics.save();
	graphics.drawTexture(image, 0, 0);
	graphics.setBlendMode(BlendMode.Mask);
	graphics.drawTexture(mask, destX, destY);
	graphics.restore();
	return texture;
}

🔹 How do I create pages and make nice transitions?

In Flambe, you can create scenes (pages) very easy using a Director and Scene classes. See Scenes & Transitions

🔹 Does Flambe use OpenFL, NME or target C++?

No. I think Stage3D performance under AIR is acceptable for most mobile games, and comes with features that aren't in NME yet (Web views, video, camera). It's possible an NME/C++ backend could be added as an option in the future, but adding a C++ backend will mean a lot of time testing and fixing native quirks. I'd rather spend that time on the HTML5 and Flash targets, and actually shipping the game I'm working on :)

🔹 Why does sprite.x = 5 does not work?

Many properties in Flambe are AnimatedFloats. Using animateTo() on an AnimatedFloat value makes it dead simple to say, spin a sprite or fade out a sound. But what if you want to do something more complicated, like chain animations together, loop them, or run code at certain times?

See Working with values

🔹 How do I do conditional compilation?

Sometimes you need two builds to be slightly different. The quick and dirty way is to use the compiler preprocessor: #if flambe_air foo() #else bar() #end will compile to foo() in AIR, and bar() in Flash and HTML5. The clean and scalable way is to add another build line to your wscript that compiles a different main class.

See Conditional compilation

⁉️ I have errors, something seems missing or wrong

Please check out Known issues limitations or consider reporting a bug/feature request

Clone this wiki locally