instantia Posted June 6, 2014 Share Posted June 6, 2014 As in Phaser to check whether the changed state of the sprite (body)?Is there any standard is a function?Or most velocity / speed / forse / rotation check? Link to comment Share on other sites More sharing options...
lewster32 Posted June 7, 2014 Share Posted June 7, 2014 You can check for any changes to any object in JavaScript by simply keeping a cached version of the property from the previous update, and comparing it to the current value. If the two differ, you can do something. Like so:// set an arbitrary property on the spritesprite.happiness = 10;// create a cached copy of that propertysprite.lastHappiness = sprite.happiness;function update() { // check to see if the current property differs from the cached version if (sprite.happiness !== sprite.lastHappiness) { // the sprite's happiness has changed so do something here } // update the cached version with the current version now all checks have been performed sprite.lastHappiness = sprite.happiness;} megan 1 Link to comment Share on other sites More sharing options...
Recommended Posts