English subtitles

← Energy Canister onTouch - HTML5 Game Development

Get Embed Code
4 Languages

Showing Revision 6 created 05/25/2016 by Udacity Robot.

  1. To get started, we add in some nice little sanity checking to ensure that we're
  2. not actually trying to do operations on null data that may cause the game to
  3. crash. Or we're not trying to set the energy on an entity that has been marked
  4. for death. If the user is not already at max energy, that means that we can go
  5. ahead and modify its value. For this purposes, we set that all energy canisters
  6. will update the physOwner.energy value by plus 10. Once that's been done, we
  7. simply call the mark for death flag to true, allowing the sweeping function to
  8. destroy this object.