Browse Source

Adding visual cue to Light2D shadow casters

Josh Engebretson 10 years ago
parent
commit
b41be3fc43

+ 9 - 1
Light2DExample/Resources/Components/ShadowCaster.js

@@ -6,11 +6,19 @@ body.bodyType = Atomic.BT_STATIC;
 body.castShadows = true;
 body.castShadows = true;
 
 
 var circle = node.createComponent("CollisionCircle2D");
 var circle = node.createComponent("CollisionCircle2D");
-circle.radius = .25;
+circle.radius = .35;
+
+var sprite2D = game.cache.getResource("Sprite2D", "Sprites/ball" + (Math.round(Math.random() * 7) + 1) + ".png");
+var sprite = node.createComponent("StaticSprite2D");
+sprite.setSprite(sprite2D);
 
 
 var x = -Light2DExample.halfWidth + (Light2DExample.halfWidth * 2) * Math.random();
 var x = -Light2DExample.halfWidth + (Light2DExample.halfWidth * 2) * Math.random();
 var y = -Light2DExample.halfHeight + (Light2DExample.halfHeight * 2) * Math.random();
 var y = -Light2DExample.halfHeight + (Light2DExample.halfHeight * 2) * Math.random();
 
 
+// tolerance towards the middle of screen
+x *= .7;
+y *= .7;
+
 node.position2D = [x, y];
 node.position2D = [x, y];
 
 
 function start() {
 function start() {

BIN
Light2DExample/Resources/Sprites/ball1.png


BIN
Light2DExample/Resources/Sprites/ball2.png


BIN
Light2DExample/Resources/Sprites/ball3.png


BIN
Light2DExample/Resources/Sprites/ball4.png


BIN
Light2DExample/Resources/Sprites/ball5.png


BIN
Light2DExample/Resources/Sprites/ball6.png


BIN
Light2DExample/Resources/Sprites/ball7.png


BIN
Light2DExample/Resources/Sprites/ball8.png