main.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. function BlankGame::create( %this )
  23. {
  24. // We need a main "Scene" we can use as our game world. The place where sceneObjects play.
  25. // Give it a global name "mainScene" since we may want to access it directly in our scripts.
  26. new Scene(mainScene);
  27. // Without a system window or "Canvas", we can't see or interact with our scene.
  28. // AppCore initialized the Canvas already
  29. // Now that we have a Canvas, we need a viewport into the scene.
  30. // Give it a global name "mainWindow" since we may want to access it directly in our scripts.
  31. new SceneWindow(mainWindow);
  32. mainWindow.profile = new GuiControlProfile();
  33. Canvas.setContent(mainWindow);
  34. // Finally, connect our scene into the viewport (or sceneWindow).
  35. // Note that a viewport comes with a camera built-in.
  36. mainWindow.setScene(mainScene);
  37. mainWindow.setCameraPosition( 0, 0 );
  38. mainWindow.setCameraSize( 100, 75 );
  39. // load some scripts and variables
  40. // exec("./scripts/someScript.cs");
  41. // let's do a little something to make sure we are up and running.
  42. // write "hello world!" :)
  43. %this.sayHello();
  44. }
  45. //-----------------------------------------------------------------------------
  46. function BlankGame::destroy( %this )
  47. {
  48. }
  49. //-----------------------------------------------------------------------------
  50. function BlankGame::sayHello( %this )
  51. {
  52. %phrase = new ImageFont();
  53. %phrase.Image = "BlankGame:Font";
  54. // Set the font size in both axis. This is in world-units and not typicaly font "points".
  55. %phrase.FontSize = "2 2";
  56. %phrase.TextAlignment = "Center";
  57. %phrase.Text = "Hello, World!";
  58. mainScene.add( %phrase );
  59. }