Add overloaded loadScene method to SceneLoader
Closed this issue · 0 comments
aallnneess commented
I want to load a Scene which I have saved via preferences.
So i need just a overloaded loadScene method which an Object SceneVo is given instead of the String sceneName.
So in this method it becomes:
sceneVO = rm.getSceneVO(sceneName);
->
this.sceneVO = sceneVo;
public SceneVO loadScene(SceneVo sceneVo, Viewport viewport, boolean customLight) {
assert engine != null : "You need to first create an engine by calling createEngine";
IntBag entities = engine.getAspectSubscriptionManager()
.get(Aspect.all())
.getEntities();
int[] ids = entities.getData();
for (int i = 0, s = entities.size(); s > i; i++) {
engine.delete(ids[i]);
}
entityFactory.clean();
//Update the engine to ensure that all pending operations are completed!!
engine.setDelta(0);
engine.process();
pixelsPerWU = rm.getProjectVO().pixelToWorld;
renderer.setPixelsPerWU(pixelsPerWU);
CullingSystem cullingSystem = engine.getSystem(CullingSystem.class);
if (cullingSystem != null)
cullingSystem.setPpwu(pixelsPerWU);
this.sceneVO = sceneVo;
world.setGravity(new Vector2(sceneVO.physicsPropertiesVO.gravityX, sceneVO.physicsPropertiesVO.gravityY));
PhysicsSystem physicsSystem = engine.getSystem(PhysicsSystem.class);
if (physicsSystem != null)
physicsSystem.setPhysicsOn(sceneVO.physicsPropertiesVO.enabled);
if (sceneVO.composite == null) {
sceneVO.composite = new CompositeVO();
}
rootEntity = entityFactory.createRootEntity(sceneVO.composite, viewport);
if (sceneVO.composite != null) {
entityFactory.initAllChildren(rootEntity, sceneVO.composite);
}
if (!customLight) {
setAmbientInfo(sceneVO);
}
actionFactory = new ActionFactory(rm.getProjectVO().libraryActions);
return sceneVO;
}
Desktop :
- OS: Windows 10
- HyperLap2D Version [latest]
Runtime :]
- Runtime Version [latest snapshot]