Hi all,
I have quite a complex game in development at the moment and i am struggling with the architecture.
I might have a few questions, and id appreciate if you could give me advice. Some of them might seem basic but i need to get rid of the doubts, often i read books, forums and blogs and get conflicting advice.
Firstly, in terms of larger games, do you use ineritance or composition for display objects?
public class GridDisplay extends Sprite
{
public function GridDisplay()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(): void
{
//draw your grid here
}
}
Usage:
var grid:GridDisplay = new GridDisplay();
addChild(grid);
Or is it best to use composition?
public class GridDisplay
{
private var _sprite:Sprite;
public function GridDisplay(gridSprite:Sprite)
{
init()
}
private function init(): void
{
_sprite.? //draw your grid here
}
public function moveToX(number:Number): void
{
_sprite.x = number;
}
}
Usage:
var gridSprite:Sprite = new Sprite();
gridSprite.x = 400;
gridSprite.y = 400;
addEventListener(gridSprite);
var grid:GridDisplay = new GridDisplay(gridSprite);
grid.moveToX(100);
What is the best approach on this?
Thanks!