Roboman.js 951 B

12345678910111213141516171819202122232425262728293031323334
  1. 'atomic component';
  2. //Roboman component
  3. exports.component = function(self) {
  4. //link to the current node
  5. var node = self.node;
  6. //get aniomatio controller component
  7. var animationController = node.getComponent("AnimationController");
  8. animationController.playExclusive("Idle", 0, true);
  9. //Listen events and play animation
  10. self.subscribeToEvent("PlayRun", function() {
  11. animationController.playExclusive("Run", 0, true);
  12. });
  13. self.subscribeToEvent("PlayIdle", function() {
  14. animationController.playExclusive("Idle", 0, true);
  15. });
  16. self.subscribeToEvent("PlayAttack", function() {
  17. animationController.playExclusive("Attack", 0, true);
  18. });
  19. self.subscribeToEvent("PlayWalk", function() {
  20. animationController.playExclusive("Walk", 0, true);
  21. });
  22. self.update = function(timeStep) {
  23. //rotate ours node around Y axis
  24. node.yaw(timeStep * 10);
  25. };
  26. };