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 Dot(stage,x,y,colours,index,radius,game,xpos,ypos){
  2. this.colour = index;
  3. this.colours = colours;
  4. this.radius = radius;
  5. this.circle = null;
  6. this.clickable = true;
  7. this.x = x;
  8. this.y = y;
  9. this.setCircle = function(){
  10. this.circle.x = this.x;
  11. this.circle.y = this.y;
  12. stage.addChild(this.circle);
  13. }
  14. this.setColour = function(index){
  15. this.circle.graphics.clear().beginFill(this.colours[index]).drawCircle(0,0,this.radius).endFill();
  16. this.colour = index;
  17. }
  18. this.flipSelf = function(){
  19. //console.log("flip");
  20. if (this.colour==0){
  21. this.colour = 1;
  22. this.setColour(1);
  23. } else {
  24. this.colour = 0;
  25. this.setColour(0);
  26. }
  27. }
  28. this.setClickListener = function(){
  29. var c = this.circle;
  30. var d = this;
  31. var g = game;
  32. this.circle.on("click", function (evt) {
  33. if (d.clickable==true){
  34. g.flip(xpos,ypos);
  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();
  68. this.setClickListener();
  69. //console.log(this.circle);
  70. }
  71. }