Faizy Posted May 19, 2017 Share Posted May 19, 2017 Hey, I need some kind of a listener, which looks 24/7 if a specific event happens and triggers a function/callback. A basic example: if a player reaches position X, a function should be triggered, which adds a scorepoint. Is it possible to define a specific event, which get´s checked 24/7 if happening, and if yes, a specific function will get fired? I cant figure out where I can set up the condition, even after reading this Thanks!. Link to comment Share on other sites More sharing options...
samme Posted May 19, 2017 Share Posted May 19, 2017 Yes, you still have to do the check yourself. It would look something like function create() { this.onPlayerReachedGoal = new Phaser.Signal(); } function update() { if player.position.distance(goal) < 1 { this.onPlayerReachedGoal.dispatch(); } } Link to comment Share on other sites More sharing options...
Recommended Posts