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.

32 lines
910 B

  1. // Light sprite class
  2. enyo.kind({
  3. name: "Sprite",
  4. published: { x: 0, y: 0, heading: 0, power: 0, images: [], engine: null },
  5. // Create component
  6. create: function() {
  7. this.inherited(arguments);
  8. },
  9. // Draw the sprite in the canvas context
  10. draw: function(ctx) {
  11. ctx.save();
  12. ctx.translate(this.x*constant.tileSize, this.y*constant.tileSize);
  13. var image = document.getElementById(this.getCurrentImage());
  14. ctx.drawImage(image, 0, 0);
  15. if (this.value !== undefined) {
  16. ctx.font="29px Arial";
  17. ctx.strokeStyle="#000000";
  18. var x = (constant.tileSize - ctx.measureText(this.value.tag).width)/2;
  19. ctx.strokeText(this.value.tag, x, 50);
  20. ctx.fillStyle="#FFFF00";
  21. ctx.fillText(this.value.tag, x+2, 51);
  22. }
  23. ctx.restore();
  24. },
  25. // Get current image of the sprite
  26. getCurrentImage: function() {
  27. return this.images[this.heading < this.images.length ? this.heading : 0];
  28. }
  29. });