Star.js 748 B

1234567891011121314151617181920212223242526272829
  1. 'atomic component';
  2. //A star component
  3. exports.component = function(self) {
  4. //link to the current node
  5. var node = self.node;
  6. //start function calls when component attached to the node, calls after constructor
  7. self.start = function() {
  8. //create StaticSprite2D component to the current node
  9. var sprite2D = node.createComponent("StaticSprite2D");
  10. //get star.png sprite from cache
  11. sprite2D.sprite = Atomic.cache.getResource("Sprite2D", "Sprites/star.png");
  12. //set blend mode to BLEND_ALPHA
  13. sprite2D.blendMode = Atomic.BLEND_ALPHA;
  14. }
  15. //update function calls each frame
  16. self.update = function(timeStep) {
  17. //roll a node
  18. node.roll(timeStep * 100);
  19. }
  20. }