Lighting.js 771 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Atomic Component
  2. var game = Atomic.game;
  3. var scene = game.scene;
  4. var node = self.node;
  5. var daytime = true;
  6. function start() {
  7. // currently lightgroup must be created after viewport 0 is set
  8. var lightGroup = node.createComponent("Light2DGroup");
  9. lightGroup.setPhysicsWorld(Platformer.physicsWorld);
  10. if (daytime)
  11. lightGroup.ambientColor = [1, 1, 1, 1];
  12. else
  13. lightGroup.ambientColor = [.8, .8, .8, .25];
  14. if (daytime)
  15. {
  16. TheSun = scene.createComponent("DirectionalLight2D");
  17. TheSun.color = [1, 1, 1, 0.15];
  18. TheSun.castShadows = true;
  19. TheSun.numRays = 1024;
  20. TheSun.backtrace = false;
  21. lightGroup.addLight(TheSun);
  22. }
  23. }
  24. function update(timeStep) {
  25. }