From 76937aeb786a4759b655b8f0ca11dc379ea0a2a0 Mon Sep 17 00:00:00 2001 From: Don Miguel Date: Wed, 21 Jan 2015 19:21:44 +0500 Subject: [PATCH] feat(Dark Rooms): Added light flickering. Changed % of occurrence to 5% Closes #9 --- src/app.js | 33 +++++++++++++++++++++++++++++++++ src/level.js | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index bf12d17..eea7a47 100644 --- a/src/app.js +++ b/src/app.js @@ -103,6 +103,31 @@ waw.MainLayer = cc.Layer.extend({ this.lightspot4.setRotation(270); this.lightspot4.setPosition(160, 120); + this.lightspot1.runAction(new cc.RepeatForever( + new cc.Sequence( + new cc.ScaleTo(0.2 + Math.random(), 0.98), + new cc.ScaleTo(0.2 + Math.random(), 1) + ) + )); + this.lightspot2.runAction(new cc.RepeatForever( + new cc.Sequence( + new cc.ScaleTo(0.2 + Math.random(), 0.98), + new cc.ScaleTo(0.2 + Math.random(), 1) + ) + )); + this.lightspot3.runAction(new cc.RepeatForever( + new cc.Sequence( + new cc.ScaleTo(0.2 + Math.random(), 0.98), + new cc.ScaleTo(0.2 + Math.random(), 1) + ) + )); + this.lightspot4.runAction(new cc.RepeatForever( + new cc.Sequence( + new cc.ScaleTo(0.2 + Math.random(), 0.98), + new cc.ScaleTo(0.2 + Math.random(), 1) + ) + )); + this.addChild(this.lightspot1, 399); this.addChild(this.lightspot2, 399); this.addChild(this.lightspot3, 399); @@ -252,6 +277,8 @@ waw.MainLayer = cc.Layer.extend({ if (room) { currentRoomY -= 1; transition = cc.TransitionSlideInT; //effect - scrolls one scene out + this.lightspot3.visible = false; + this.lightspot4.visible = false; } else return; break; @@ -260,6 +287,8 @@ waw.MainLayer = cc.Layer.extend({ if (room) { currentRoomY += 1; transition = cc.TransitionSlideInB; + this.lightspot1.visible = false; + this.lightspot2.visible = false; } else return; break; @@ -268,6 +297,8 @@ waw.MainLayer = cc.Layer.extend({ if (room) { currentRoomX -= 1; transition = cc.TransitionSlideInL; + this.lightspot2.visible = false; + this.lightspot3.visible = false; } else return; break; @@ -276,6 +307,8 @@ waw.MainLayer = cc.Layer.extend({ if (room) { currentRoomX += 1; transition = cc.TransitionSlideInR; + this.lightspot1.visible = false; + this.lightspot4.visible = false; } else return; break; diff --git a/src/level.js b/src/level.js index 4298108..4d6c09b 100644 --- a/src/level.js +++ b/src/level.js @@ -69,7 +69,7 @@ rooms.genLevel = function() { r.walls.bottom = "start"; r.type = 0; //clean room. no obstacles in it } else { - if(Math.random() <= 0.1) + if(Math.random() <= 0.05) r.dark = true; }