Background.js 728 B

123456789101112131415161718192021222324
  1. 'atomic component';
  2. //A Background component
  3. exports.component = function(self) {
  4. //Link to the current node
  5. var node = self.node;
  6. //Get main camera of the current scene
  7. var camera = node.scene.getMainCamera();
  8. //set its ortho size
  9. camera.orthoSize = Atomic.graphics.height * Atomic.PIXEL_SIZE;
  10. //Get StaticSprite2D component from the current node
  11. var sprite2D = node.getComponent("StaticSprite2D");
  12. var width = sprite2D.sprite.texture.width;
  13. var height = sprite2D.sprite.texture.height;
  14. var viewWidth = Atomic.graphics.width;
  15. var viewHeight = Atomic.graphics.height;
  16. //scale the current node with X and Y
  17. node.scale2D = [viewWidth / width, viewHeight / height];
  18. };