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.

62 lines
1.9 KiB

  1. define(["sugar-web/activity/activity",'easeljs','tweenjs','activity/game','activity/standardabacus','activity/standardabacuscolumn','activity/abacusbead','activity/onecolumnabacus','activity/posnegcolumn'], 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","fraction","activity/abacuspalette","activity/custompalette"], function(env,datastore,fraction,abacuspalette,custompalette) {
  6. act.setup();
  7. act.getXOColor(function (error, colors) {
  8. runactivity(act,doc,colors,env,datastore,fraction,abacuspalette,custompalette);
  9. });
  10. });
  11. });
  12. });
  13. function runactivity(act,doc,colors,env,datastore,fraction,abacuspalette,custompalette){
  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.Touch.enable(stage);
  26. createjs.Ticker.setFPS(30);
  27. createjs.Ticker.addEventListener("tick", handleTick);
  28. function handleTick() {
  29. stage.update();
  30. }
  31. var g = new Game(act,stage,colors,fraction,doc,abacuspalette,custompalette,datastore);
  32. setTimeout(function(){ g.init(); }, 500);
  33. window.addEventListener('activityStop', function (eve) {
  34. eve.preventDefault();
  35. g.stop();
  36. });
  37. window.addEventListener('resize', resizeCanvas, false);
  38. function resizeCanvas() {
  39. canvas.width = window.innerWidth;
  40. canvas.height = window.innerHeight-55;
  41. g.resize();
  42. }
  43. var clearButton = doc.getElementById("clear-button");
  44. clearButton.addEventListener('click', function (a) {
  45. g.clear();
  46. });
  47. var copyButton = doc.getElementById("copy-button");
  48. copyButton.addEventListener('click', function (a) {
  49. g.copy();
  50. });
  51. }
  52. init();
  53. }