main.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 DeadlyReef::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. exec("./scripts/aquarium.cs");
  42. buildAquarium(mainScene);
  43. createAquariumEffects(mainScene);
  44. DeadlyReef.spawnPlayerFish();
  45. }
  46. //-----------------------------------------------------------------------------
  47. function DeadlyReef::destroy( %this )
  48. {
  49. }
  50. //-----------------------------------------------------------------------------
  51. function DeadlyReef::spawnPlayerFish(%this)
  52. {
  53. %anim = "TropicalAssets:seahorseAnim";
  54. %size = getFishSize(%anim);
  55. %fish = new Sprite()
  56. {
  57. Animation = %anim;
  58. // class = "FishClass";
  59. position = "0 0";
  60. size = %size;
  61. SceneLayer = "15";
  62. SceneGroup = "14";
  63. minSpeed = "5";
  64. maxSpeed = "15";
  65. CollisionCallback = true;
  66. };
  67. %fish.createPolygonBoxCollisionShape(%size);
  68. %fish.setCollisionShapeIsSensor(0, true);
  69. %fish.setCollisionGroups( "15" );
  70. mainScene.add( %fish );
  71. }