|
|
@@ -9,15 +9,19 @@ var node = self.node;
|
|
|
|
|
|
// Resources
|
|
|
var animationSet = cache.getResource("AnimationSet2D", "Sprites/GoldIcon.scml");
|
|
|
-var coinSound = cache.getResource("Sound","Sounds/Pickup_Coin8.ogg");
|
|
|
-var coinBounceSound = cache.getResource("Sound","Sounds/Coin_Bounce.ogg");
|
|
|
+var coinSound = cache.getResource("Sound", "Sounds/Pickup_Coin8.ogg");
|
|
|
+var coinBounceSound = cache.getResource("Sound", "Sounds/Coin_Bounce.ogg");
|
|
|
|
|
|
var sprite = node.createComponent("AnimatedSprite2D");
|
|
|
sprite.setAnimation(animationSet, "idle");
|
|
|
sprite.setLayer(100);
|
|
|
|
|
|
var light = node.createComponent("PointLight2D");
|
|
|
-light.color = [1, 1, .56, .8];
|
|
|
+if (daytime)
|
|
|
+ light.color = [1, 1, .56, .4];
|
|
|
+else
|
|
|
+ light.color = [1, 1, .56, .8];
|
|
|
+
|
|
|
light.radius = .85;
|
|
|
lightGroup.addLight(light);
|
|
|
|
|
|
@@ -28,30 +32,27 @@ var body;
|
|
|
function onPlayerHit() {
|
|
|
|
|
|
//ThePlayer.light.enabled = false;
|
|
|
-
|
|
|
+
|
|
|
// sprite enabled is not removing the sprite
|
|
|
light.enabled = false;
|
|
|
node.scale2D = [0, 0];
|
|
|
sprite.enabled = false;
|
|
|
- body.enabled = false;
|
|
|
+ body.enabled = false;
|
|
|
self.soundSource.gain = 1.0;
|
|
|
- self.soundSource.play(coinSound );
|
|
|
-
|
|
|
+ self.soundSource.play(coinSound);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
self.onPhysicsBeginContact2D = function(world, bodyA, bodyB, nodeA, nodeB) {
|
|
|
|
|
|
if (nodeA == ThePlayer.node && nodeB == node) {
|
|
|
onPlayerHit();
|
|
|
- }
|
|
|
- else if (nodeB == node)
|
|
|
- {
|
|
|
+ } else if (nodeB == node) {
|
|
|
var vel = body.linearVelocity;
|
|
|
- if (vec2.length(vel) > 3)
|
|
|
- {
|
|
|
- self.soundSource.gain = .4;
|
|
|
+ if (vec2.length(vel) > 3) {
|
|
|
+ self.soundSource.gain = .3;
|
|
|
self.soundSource.play(coinBounceSound);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -61,10 +62,10 @@ function start() {
|
|
|
|
|
|
self.soundSource = node.createComponent("SoundSource");
|
|
|
self.soundSource.soundType = Atomic.SOUND_EFFECT;
|
|
|
-
|
|
|
+
|
|
|
// would just like to listen to body collisions here
|
|
|
self.listenToEvent(null, "PhysicsBeginContact2D", self.onPhysicsBeginContact2D);
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -82,7 +83,7 @@ function update(timeStep) {
|
|
|
body.castShadows = false;
|
|
|
|
|
|
var circle = node.createComponent("CollisionCircle2D");
|
|
|
-
|
|
|
+
|
|
|
// Set radius
|
|
|
circle.setRadius(.3);
|
|
|
// Set density
|