Imp.js 763 B

12345678910111213141516171819202122232425262728293031
  1. 'atomic component';
  2. //Imp component
  3. exports.component = function(self) {
  4. //Link to the current node
  5. var node = self.node;
  6. var animatedSprite = node.getComponent("AnimatedSprite2D");
  7. //Listen events and set animation
  8. self.subscribeToEvent("PlayRun", function() {
  9. animatedSprite.setAnimation("run");
  10. });
  11. self.subscribeToEvent("PlayIdle", function() {
  12. animatedSprite.setAnimation("idle");
  13. });
  14. self.subscribeToEvent("PlayAttack", function() {
  15. animatedSprite.setAnimation("attack");
  16. });
  17. self.subscribeToEvent("PlayHit", function() {
  18. animatedSprite.setAnimation("hit");
  19. });
  20. self.subscribeToEvent("PlayDead", function() {
  21. animatedSprite.setAnimation("dead");
  22. });
  23. };