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.

76 lines
1.9 KiB

  1. function SymmetryDot(stage,clickable,x,y,radius,colours,index,game,xpos,ypos){
  2. this.clickable = clickable;
  3. this.colour = index;
  4. this.colours = colours;
  5. this.radius = radius;
  6. this.circle = null;
  7. this.setCircle = function(x,y){
  8. this.circle.x = x;
  9. this.circle.y = y;
  10. stage.addChild(this.circle);
  11. }
  12. this.getNewColour = function(){
  13. this.colour++;
  14. if (this.colour>(this.colours.length-1)){
  15. this.colour = 0;
  16. }
  17. }
  18. this.setColour = function(index){
  19. this.circle.graphics.clear().beginFill(this.colours[index]).drawCircle(0,0,this.radius).endFill();
  20. this.colour = index;
  21. }
  22. this.setClickListener = function(){
  23. var c = this.circle;
  24. var d = this;
  25. var g = game;
  26. this.circle.on("click", function (evt) {
  27. if (d.clickable==true){
  28. d.getNewColour();
  29. console.log(d.colours[d.colour]);
  30. d.setColour(d.colour);
  31. if (g.robot){
  32. g.robotColours(xpos,ypos,d.colour);
  33. }
  34. g.checkColours();
  35. }
  36. });
  37. }
  38. this.showSmile = function(){
  39. var s = new createjs.Shape();
  40. var g = s.graphics;
  41. var scale = 150;
  42. var colour = "";
  43. if (this.colours[this.colour]=="#000"||this.colours[this.colour]=="#000000"){
  44. colour = "#FFFFFF";
  45. } else {
  46. colour = "#000000";
  47. }
  48. g.setStrokeStyle(10/scale*this.radius, 'round', 'round');
  49. g.beginStroke(colour);
  50. g.beginFill();
  51. g.drawCircle(0, 0, 100/scale*this.radius);
  52. g.beginFill();
  53. g.arc(0, 0, 60/scale*this.radius, 0, Math.PI);
  54. g.beginStroke();
  55. g.beginFill(colour);
  56. g.drawCircle(-30/scale*this.radius, -30/scale*this.radius, 15/scale*this.radius);
  57. g.drawCircle(30/scale*this.radius, -30/scale*this.radius, 15/scale*this.radius);
  58. s.x = this.circle.x;
  59. s.y = this.circle.y;
  60. stage.addChild(s);
  61. //console.log(s);
  62. }
  63. this.init = function(){
  64. var circle = new createjs.Shape();
  65. circle.graphics.beginFill(this.colours[this.colour]).drawCircle(0,0,this.radius).endFill();
  66. this.circle = circle;
  67. this.setCircle(x,y);
  68. this.setClickListener();
  69. //console.log(this.circle);
  70. }
  71. }