как работает Genome2D?
Хочу попробовать переделать приложение со старлинга на геном,
но не могу понять как у него работает система координат,
вроде все понятно, но отображается какая-то лажа.
Код такой:
Код AS3:
private function createGenome():void
{
Genome2D.getInstance().onInitialized.addOnce(onGenomeInitialized);
Genome2D.getInstance().init(stage, new GContextConfig());
}
private function onGenomeInitialized():void
{
trace("onGenomeInitialized");
var genome2D:Genome2D = Genome2D.getInstance();
_container = GNodeFactory.createNode("container");
genome2D.root.addChild(_container);
genome2D.onCameraAdded.addOnce(onCameraAdded);
_cameraNode = GNodeFactory.createNode("camera");
var camera:GCamera = _container.addComponent(GCamera) as GCamera;
_container.addChild(_cameraNode);
}
private function onCameraAdded(gCamera:GCamera):void
{
var texture:GTexture = GTextureFactory.createFromBitmapData("texture", new BitmapData(stage.fullScreenWidth, stage.fullScreenHeight, false, 0xFF0000), true);
var sprite:GSprite = GNodeFactory.createNodeWithComponent(GSprite, "sprite") as GSprite;
sprite.setTexture(texture);
_container.addChild(sprite.node);
texture = GTextureFactory.createFromBitmapData("textureId", (new wallClass() as Bitmap).bitmapData, true);
var i:int = 10;
var j:int = 10;
while (i--)
{
while (j--)
{
sprite = GNodeFactory.createNodeWithComponent(GSprite, "sprite" + i + j) as GSprite;
sprite.setTexture(texture);
sprite.node.onMouseDown.add(onMouseDownHandler);
sprite.node.onMouseMove.add(onMouseMoveHandler);
sprite.node.onMouseUp.add(onMouseUpHandler);
sprite.node.transform.x = i * 64;
sprite.node.transform.y = j * 64;
_container.addChild(sprite.node);
}
j = 10;
}
}
Фон и остальные кубы с текстурой по идее должны быть в одной координатной плоскости, но нифига..
Бибиотека Генома: https://github.com/pshtif/Genome2D/downloads
|