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.

73 lines
2.2 KiB

  1. define(["sugar-web/activity/activity", "webL10n", 'easeljs','tweenjs','activity/game','activity/flipdot'], function (act, webL10n) {
  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","activity/sizepalette"], function(env,datastore,sizepalette) {
  6. act.setup();
  7. act.getXOColor(function (error, colors) {
  8. runactivity(act,doc,colors,env,datastore,sizepalette);
  9. });
  10. env.getEnvironment(function(err, environment) {
  11. currentenv = environment;
  12. // Set current language to Sugarizer
  13. var defaultLanguage = (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) ? chrome.i18n.getUILanguage() : navigator.language;
  14. var language = environment.user ? environment.user.language : defaultLanguage;
  15. webL10n.language.code = language;
  16. });
  17. });
  18. });
  19. });
  20. function runactivity(act,doc,colors,env,datastore,sizepalette){
  21. var canvas;
  22. var stage;
  23. var g;
  24. var e;
  25. function init(){
  26. canvas = document.getElementById('actualcanvas');
  27. canvas.width = window.innerWidth;
  28. canvas.height = window.innerHeight-200;
  29. stage = new createjs.Stage(canvas);
  30. stage.update();
  31. stage.mouseEventsEnabled = true;
  32. document.getElementById("flip-count").style.color = colors['stroke'];
  33. document.getElementById("fliptext").style.borderBottom = "5px solid #00ff1b";
  34. createjs.Ticker.setFPS(30);
  35. createjs.Ticker.addEventListener("tick", handleTick);
  36. function handleTick() {
  37. stage.update();
  38. }
  39. var g = new Game(stage,colors,doc,datastore,act,sizepalette);
  40. setTimeout(function(){ g.init(); }, 500);
  41. var hasBeenResized = false;
  42. window.addEventListener('resize', resizeCanvas, false);
  43. function resizeCanvas() {
  44. canvas.width = window.innerWidth;
  45. canvas.height = window.innerHeight-200;
  46. g.initialiseFromArray();
  47. }
  48. var solveButton = doc.getElementById("solve-button");
  49. solveButton.addEventListener('click', function (a) {
  50. g.solve();
  51. });
  52. var newGameButton = doc.getElementById("new-game-button");
  53. newGameButton.addEventListener('click', function (a) {
  54. g.newGame();
  55. });
  56. window.addEventListener('activityStop', function (eve) {
  57. eve.preventDefault();
  58. g.stop();
  59. });
  60. }
  61. init();
  62. }