not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.3 KiB

  1. define(["sugar-web/activity/activity",'easeljs','tweenjs','activity/game','activity/symmetrydot'], function (act) {
  2. // Manipulate the DOM only when it is ready.
  3. requirejs(['domReady!'], function (doc) {
  4. // Initialize the activity.
  5. requirejs(["sugar-web/env","sugar-web/datastore"], function(env,datastore) {
  6. act.setup();
  7. act.getXOColor(function (error, colors) {
  8. runactivity(act,doc,colors,env,datastore);
  9. });
  10. });
  11. });
  12. });
  13. function runactivity(act,doc,colors,env,datastore){
  14. var canvas;
  15. var stage;
  16. var g;
  17. var e;
  18. function init(){
  19. canvas = document.getElementById('actualcanvas');
  20. canvas.width = window.innerWidth;
  21. canvas.height = window.innerHeight-55;
  22. stage = new createjs.Stage(canvas);
  23. stage.update();
  24. stage.mouseEventsEnabled = true;
  25. createjs.Ticker.setFPS(30);
  26. createjs.Ticker.addEventListener("tick", handleTick);
  27. function handleTick() {
  28. stage.update();
  29. }
  30. g = new Game(stage,colors,doc,datastore,act);
  31. setTimeout(function(){ g.init(); }, 500);
  32. var hasBeenResized = false;
  33. window.addEventListener('resize', resizeCanvas, false);
  34. function resizeCanvas() {
  35. canvas.width = window.innerWidth;
  36. canvas.height = window.innerHeight-55;
  37. stage.removeAllChildren();
  38. g.resize();
  39. }
  40. var buddyButton = doc.getElementById("buddy-button");
  41. buddyButton.addEventListener('click', function (a) {
  42. stage.removeAllChildren();
  43. g.initBuddy();
  44. });
  45. var rainbowButton = doc.getElementById("rainbow-button");
  46. rainbowButton.addEventListener('click', function (a) {
  47. stage.removeAllChildren();
  48. g.initRainbow();
  49. });
  50. var horizontalButton = doc.getElementById("horizontal-button");
  51. horizontalButton.addEventListener('click', function (a) {
  52. stage.removeAllChildren();
  53. g.initHorizontalGame();
  54. });
  55. var verticalButton = doc.getElementById("vertical-button");
  56. verticalButton.addEventListener('click', function (a) {
  57. stage.removeAllChildren();
  58. g.initVerticalGame();
  59. });
  60. var bilateralButton = doc.getElementById("bilateral-button");
  61. bilateralButton.addEventListener('click', function (a) {
  62. stage.removeAllChildren();
  63. g.initBilateralGame();
  64. });
  65. var robotButton = doc.getElementById("robot-button");
  66. robotButton.addEventListener('click', function (a) {
  67. g.toggleRobot();
  68. });
  69. window.addEventListener('activityStop', function (eve) {
  70. eve.preventDefault();
  71. g.stop();
  72. });
  73. }
  74. init();
  75. }