Lighting.js 828 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Atomic Component
  2. var game = Atomic.game;
  3. var scene = game.scene;
  4. var node = self.node;
  5. var daytime = Platformer.daytime;
  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. Platformer.lightGroup = lightGroup;
  11. if (daytime)
  12. lightGroup.ambientColor = [1, 1, 1, 1];
  13. else
  14. lightGroup.ambientColor = [.8, .8, .8, .25];
  15. if (daytime)
  16. {
  17. TheSun = scene.createComponent("DirectionalLight2D");
  18. TheSun.color = [1, 1, 1, 0.15];
  19. TheSun.castShadows = true;
  20. TheSun.numRays = 1024;
  21. TheSun.backtrace = false;
  22. lightGroup.addLight(TheSun);
  23. }
  24. }
  25. function update(timeStep) {
  26. }