misfit Posted March 15, 2018 Share Posted March 15, 2018 So i want to add listener to when the sprite goes out of bounds of the screen. It doesn't seem to fire up. Am I missing something? I saw a post here about this but it uses this.physics.world.on("worldbounds".. but isn't there a way to encapsulate the listener inside a new Sprite child class? Btw is there a list of events i can listen to? Thanks! class Meteor extends Phaser.Physics.Arcade.Sprite{ constructor(scene,x,y,key_texture,frame){ super(scene,x,y,key_texture,frame); this.scene = scene; this.scene.addToWorld(this); this.scene.physics.add.existing(this,false); this.setCollideWorldBounds(true); this.addListener("onOutOfBounds",()=>{console.log("hello")}); } } Ok so apparently if i am setting this.collideWorldBounds(true) it console.logs this.body.onWOrlBounds as true but console.log this has it set to false. If I add a new Meteor(..) from scene.create() method it works fine. If I add it from Spawner class it doesn't. Link to comment Share on other sites More sharing options...
Recommended Posts