main.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. camera.setOrthoSize(Atomic.graphics.height * Atomic.PIXEL_SIZE / 2);
  12. // create a viewport
  13. var viewport = new Atomic.Viewport(scene, camera);
  14. Atomic.renderer.setViewport(0, viewport);
  15. // create our spawner component
  16. scene.createJSComponent("Components/Spawner.js");
  17. createInstructions();
  18. function createInstructions() {
  19. var view = new Atomic.UIView();
  20. // Create a layout, otherwise child widgets won't know how to size themselves
  21. // and would manually need to be sized
  22. var layout = new Atomic.UILayout();
  23. // specify the layout region
  24. layout.rect = view.rect;
  25. view.addChild(layout);
  26. // we're laying out on the X axis so "position" controls top and bottom alignment
  27. layout.layoutPosition = Atomic.UI_LAYOUT_POSITION_RIGHT_BOTTOM;
  28. // while "distribution" handles the Y axis
  29. layout.layoutDistributionPosition = Atomic.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM;
  30. var fd = new Atomic.UIFontDescription();
  31. fd.id = "Vera";
  32. fd.size = 18;
  33. var scoreText = new Atomic.UIEditField();
  34. scoreText.fontDescription = fd;
  35. scoreText.readOnly = true;
  36. scoreText.multiline = true;
  37. scoreText.adaptToContentSize = true;
  38. scoreText.text = "Atomic Butterflies\nLeft Mouse - Spawn Butterflies\nRight Click - Spawn Particles";
  39. layout.addChild(scoreText);
  40. }