Hello everybody,
I want to trigger a ‘changeScene’ when an entity reach a certain position.
This is how I achieve it it currently.
I attached a script to my moving entity and when this entity reaches past a certain position the scene changes.
GotoMainscene.prototype.update = function(dt) {
var entityPos = this.entity.getPosition();
console.log(entityPos);
if(entityPos.x>-2){
this.app.scenes.changeScene("main");
}
};
The problem is that I don’t think this is the smart way of to do it.
And doing so causes many problems. It is like calling the changeScene(“main”) not once but many times.
does anybody know a better way to do it ? Getting to a different scene triggered by the position of an object ?