![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
package {
import com.pblabs.engine.PBE;
import com.pblabs.engine.entity.IEntity;
import com.pblabs.engine.entity.PropertyReference;
import com.pblabs.rendering2D.SimpleSpatialComponent;
import com.pblabs.rendering2D.SpriteRenderer;
import com.pblabs.rendering2D.ui.SceneView;
import flash.display.Sprite;
import flash.geom.Point;
//[SWF(width="800", height="500", frameRate="60")]
public class MainApp extends Sprite
{
public function MainApp()
{
PBE.startup(this);//启动pushButton
createScene();
}
private function createScene():void
{
var sceneView:SceneView=new SceneView();
PBE.initializeScene(sceneView);
sceneView.width=500;
sceneView.height=400;
}
private function createHero():void
{
var hero:IEntity=PBE.allocateEntity();
hero.initialize("Hero");
var spatial:SimpleSpatialComponent=new SimpleSpatialComponent();
spatial.position=new Point(0,0);
spatial.size=new Point(20,20);
hero.addComponent(spatial,"Spatial");
var render:SpriteRenderer=new SpriteRenderer();
render.fileName="assets/palnt.png";
render.positionProperty=new PropertyReference("@Spatial.position");
render.sizeProperty=new PropertyReference("@Spatial.size");
hero.addComponent(render,"Render");
}
}
}
import com.pblabs.engine.PBE;
import com.pblabs.engine.entity.IEntity;
import com.pblabs.engine.entity.PropertyReference;
import com.pblabs.rendering2D.SimpleSpatialComponent;
import com.pblabs.rendering2D.SpriteRenderer;
import com.pblabs.rendering2D.ui.SceneView;
import flash.display.Sprite;
import flash.geom.Point;
//[SWF(width="800", height="500", frameRate="60")]
public class MainApp extends Sprite
{
public function MainApp()
{
PBE.startup(this);//启动pushButton
createScene();
}
private function createScene():void
{
var sceneView:SceneView=new SceneView();
PBE.initializeScene(sceneView);
sceneView.width=500;
sceneView.height=400;
}
private function createHero():void
{
var hero:IEntity=PBE.allocateEntity();
hero.initialize("Hero");
var spatial:SimpleSpatialComponent=new SimpleSpatialComponent();
spatial.position=new Point(0,0);
spatial.size=new Point(20,20);
hero.addComponent(spatial,"Spatial");
var render:SpriteRenderer=new SpriteRenderer();
render.fileName="assets/palnt.png";
render.positionProperty=new PropertyReference("@Spatial.position");
render.sizeProperty=new PropertyReference("@Spatial.size");
hero.addComponent(render,"Render");
}
}
}
向舞台添加一个角色,角色是由"assets/palnt.png"渲染的