Imp.js 677 B

1234567891011121314151617181920212223242526272829
  1. 'atomic component';
  2. exports.component = function(self) {
  3. var node = self.node;
  4. var animatedSprite = node.getComponent("AnimatedSprite2D");
  5. self.subscribeToEvent("PlayRun", function() {
  6. animatedSprite.setAnimation("run");
  7. });
  8. self.subscribeToEvent("PlayIdle", function() {
  9. animatedSprite.setAnimation("idle");
  10. });
  11. self.subscribeToEvent("PlayAttack", function() {
  12. animatedSprite.setAnimation("attack");
  13. });
  14. self.subscribeToEvent("PlayHit", function() {
  15. animatedSprite.setAnimation("hit");
  16. });
  17. self.subscribeToEvent("PlayDead", function() {
  18. animatedSprite.setAnimation("dead");
  19. });
  20. }