Imp.js 863 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(Atomic.ScriptEvent("PlayRun", function() {
  9. animatedSprite.setAnimation("run");
  10. }));
  11. self.subscribeToEvent(Atomic.ScriptEvent("PlayIdle", function() {
  12. animatedSprite.setAnimation("idle");
  13. }));
  14. self.subscribeToEvent(Atomic.ScriptEvent("PlayAttack", function() {
  15. animatedSprite.setAnimation("attack");
  16. }));
  17. self.subscribeToEvent(Atomic.ScriptEvent("PlayHit", function() {
  18. animatedSprite.setAnimation("hit");
  19. }));
  20. self.subscribeToEvent(Atomic.ScriptEvent("PlayDead", function() {
  21. animatedSprite.setAnimation("dead");
  22. }));
  23. };