main.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // This script is the main entry point of the game
  2. // create a scene
  3. var scene = new Atomic.Scene();
  4. // create an octree component
  5. scene.createComponent("Octree");
  6. // create out camera
  7. var cameraNode = scene.createChild("Camera");
  8. var camera = cameraNode.createComponent("Camera");
  9. // setup as 2D
  10. camera.setOrthographic(true);
  11. //Atomic.PIXEL_SIZE / 2 means that our pixels are doubled up
  12. camera.setOrthoSize(Atomic.graphics.height * Atomic.PIXEL_SIZE / 2);
  13. // create a viewport
  14. var viewport = new Atomic.Viewport(scene, camera);
  15. Atomic.renderer.setViewport(0, viewport);
  16. // create our spawner component
  17. scene.createJSComponent("Components/Spawner.js");
  18. createInstructions();
  19. function createInstructions() {
  20. var view = new Atomic.UIView();
  21. // Create a layout, otherwise child widgets won't know how to size themselves
  22. // and would manually need to be sized
  23. var layout = new Atomic.UILayout();
  24. // specify the layout region
  25. layout.rect = view.rect;
  26. view.addChild(layout);
  27. // we're laying out on the X axis so "position" controls top and bottom alignment
  28. layout.layoutPosition = Atomic.UI_LAYOUT_POSITION_RIGHT_BOTTOM;
  29. // while "distribution" handles the Y axis
  30. layout.layoutDistributionPosition = Atomic.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM;
  31. var fd = new Atomic.UIFontDescription();
  32. fd.id = "Vera";
  33. fd.size = 18;
  34. var scoreText = new Atomic.UIEditField();
  35. scoreText.fontDescription = fd;
  36. scoreText.readOnly = true;
  37. scoreText.multiline = true;
  38. scoreText.adaptToContentSize = true;
  39. scoreText.text = "Atomic Butterflies\nLeft Mouse - Spawn Butterflies\nRight Click - Spawn Particles";
  40. layout.addChild(scoreText);
  41. }