浏览代码

Noting a todo on BunnyMark

Josh Engebretson 10 年之前
父节点
当前提交
2f93a84bed
共有 1 个文件被更改,包括 8 次插入3 次删除
  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 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;
 
 scene.subscribeToEvent("MouseButtonDown", function() {
@@ -59,6 +64,7 @@ exports.update = function() {
             for (var i = 0; i < amount; i++) {
 
                 var node = scene.createChild();
+                nodes.push(node);
                 var bunny = node.createComponent("StaticSprite2D");
                 bunny.blendMode = Atomic.BLEND_ALPHA;
                 bunny.sprite = currentTexture;
@@ -82,7 +88,6 @@ exports.update = function() {
 
     }
 
-
     for (var i = 0; i < bunnys.length; i++) {
 
         var bunny = bunnys[i];
@@ -107,7 +112,7 @@ exports.update = function() {
         } else if (p[1] < minY) {
             bunny.speedY *= -0.95;
             //bunny.spin = (Math.random() - 0.5) * 0.2
-            
+
             if (Math.random() > 0.5) {
                 bunny.speedY -= Math.random() * 6;
             }
@@ -122,4 +127,4 @@ exports.update = function() {
 }
 
 
-;
+;