Roboman.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var game = Atomic.game;
  2. var node = self.node;
  3. RoboMan = self;
  4. self.animCtrl = node.createComponent("AnimationController");
  5. var idle = true;
  6. self.playAnimation = function(animation) {
  7. self.animCtrl.playExclusive("Models/" + animation, 0, true, 0.1);
  8. }
  9. function start() {
  10. var cache = game.cache;
  11. var model = node.createComponent("AnimatedModel");
  12. model.setModel(cache.getResource("Model", "Models/RoboMan.mdl"));
  13. model.setMaterial(cache.getResource("Material", "Materials/Robot_01_Diffuse.xml"));
  14. model.castShadows = true;
  15. self.animCtrl.playExclusive("Models/RoboMan_Normal_Walk.ani", 0, true, 0.0);
  16. game.cameraNode.position = [0, 6.0, -12];
  17. game.cameraNode.pitch(0);
  18. // Grid Plane
  19. planeNode = game.scene.createChild("Plane");
  20. planeNode.scale = [100.0, 1.0, 100.0];
  21. var planeObject = planeNode.createComponent("StaticModel");
  22. var planeModel = game.cache.getResource("Model", "Models/Plane.mdl");
  23. var gridMaterial = game.cache.getResource("Material", "Materials/BlueGrid.xml");
  24. planeObject.model = planeModel;
  25. planeObject.material = gridMaterial;
  26. node.yaw(120);
  27. }
  28. // we need an update or it doesn't run the start, fix in JSVM
  29. function update(timeStep) {
  30. node.yaw(timeStep * 50);
  31. planeNode.yaw(timeStep * 50);
  32. }