PhysicsPlatformer.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. cache = GetResourceCache();
  2. graphics = GetGraphics();
  3. renderer = GetRenderer();
  4. engine = GetEngine();
  5. input = GetInput();
  6. ui = GetUI();
  7. gameui = GetGameUI();
  8. var halfWidth = graphics.width * Atomic.PIXEL_SIZE * 0.5;
  9. var halfHeight = graphics.height * Atomic.PIXEL_SIZE * 0.5;
  10. var enableDebugHud = false;
  11. function Start() {
  12. if (enableDebugHud) {
  13. var uiStyle = cache.getResource("XMLFile", "UI/DefaultStyle.xml");
  14. var debugHud = engine.createDebugHud();
  15. debugHud.defaultStyle = uiStyle;
  16. debugHud.toggleAll();
  17. }
  18. CreateScene();
  19. }
  20. function Update() {
  21. // physicsWorld.drawDebugGeometry();
  22. }
  23. function CreateScene() {
  24. scene = new Atomic.Scene();
  25. scene.createComponent("Octree");
  26. scene.createComponent("DebugRenderer");
  27. physicsWorld = scene.createComponent("PhysicsWorld2D");
  28. physicsWorld.continuousPhysics = false;
  29. physicsWorld.subStepping = false;
  30. cameraNode = scene.createChild("Camera");
  31. cameraNode.position = [0.0, 0.0, -10.0];
  32. camera = cameraNode.createComponent("Camera");
  33. camera.orthographic = true;
  34. camera.orthoSize = graphics.height * Atomic.PIXEL_SIZE;
  35. var viewport = new Atomic.Viewport(scene, camera);
  36. renderer.setViewport(0, viewport);
  37. levelNode = scene.createChild("Level");
  38. levelNode.createJSComponent("Level");
  39. avatarNode = scene.createChild("Avatar");
  40. avatarNode.createJSComponent("Avatar");
  41. backgroundNode = scene.createChild("Background");
  42. backgroundNode .createJSComponent("Background");
  43. }