Browse Source

Noting a todo on BunnyMark

Josh Engebretson 10 years ago
parent
commit
2f93a84bed
1 changed files with 8 additions and 3 deletions
  1. 8 3
      BunnyMark/Resources/Scripts/main.js

+ 8 - 3
BunnyMark/Resources/Scripts/main.js

@@ -31,6 +31,11 @@ var count = 0;
 var amount = 10;
 var amount = 10;
 var gravity = -0.5;
 var gravity = -0.5;
 
 
+// TODO: we hold a reference to the node in script, otherwise it is GC'd
+// and the object rewrapped every time bunny.node is accessed!
+
+var nodes = [];
+
 var isAdding = false;
 var isAdding = false;
 
 
 scene.subscribeToEvent("MouseButtonDown", function() {
 scene.subscribeToEvent("MouseButtonDown", function() {
@@ -59,6 +64,7 @@ exports.update = function() {
             for (var i = 0; i < amount; i++) {
             for (var i = 0; i < amount; i++) {
 
 
                 var node = scene.createChild();
                 var node = scene.createChild();
+                nodes.push(node);
                 var bunny = node.createComponent("StaticSprite2D");
                 var bunny = node.createComponent("StaticSprite2D");
                 bunny.blendMode = Atomic.BLEND_ALPHA;
                 bunny.blendMode = Atomic.BLEND_ALPHA;
                 bunny.sprite = currentTexture;
                 bunny.sprite = currentTexture;
@@ -82,7 +88,6 @@ exports.update = function() {
 
 
     }
     }
 
 
-
     for (var i = 0; i < bunnys.length; i++) {
     for (var i = 0; i < bunnys.length; i++) {
 
 
         var bunny = bunnys[i];
         var bunny = bunnys[i];
@@ -107,7 +112,7 @@ exports.update = function() {
         } else if (p[1] < minY) {
         } else if (p[1] < minY) {
             bunny.speedY *= -0.95;
             bunny.speedY *= -0.95;
             //bunny.spin = (Math.random() - 0.5) * 0.2
             //bunny.spin = (Math.random() - 0.5) * 0.2
-            
+
             if (Math.random() > 0.5) {
             if (Math.random() > 0.5) {
                 bunny.speedY -= Math.random() * 6;
                 bunny.speedY -= Math.random() * 6;
             }
             }
@@ -122,4 +127,4 @@ exports.update = function() {
 }
 }
 
 
 
 
-;
+;