Skip to content

Commit

Permalink
Made the behaviour of FunctionObject draw calls more sensible
Browse files Browse the repository at this point in the history
They are now combined into a single loop rather than being called
individually if they were initialised after the initial initialisation.
  • Loading branch information
varkor committed Feb 8, 2016
1 parent a796c23 commit 1b7fda5
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions battle/scripts/functions/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,28 @@ FunctionObject = {
object.canvas.parentElement.removeChild(object.canvas);
FunctionObject.objects.removeElementsOfValue(entry);
};
if (FunctionObject.initialised)
FunctionObject.initialise(entry);
if (FunctionObject.initialised && entry.initialise) {
entry.object.initialise();
}
return object;
},
initialise : function (objects) {
if (arguments.length < 1) {
objects = FunctionObject.objects;
FunctionObject.initialised = true;
} else {
objects = wrapArray(objects);
}
foreach(objects, function (object) {
initialise : function () {
if (FunctionObject.initialised)
return;
FunctionObject.initialised = true;
foreach(FunctionObject.objects, function (object) {
if (object.initialise)
object.object.initialise();
});
window.setInterval(function () {
foreach(objects, function (object) {
foreach(FunctionObject.objects, function (object) {
if (object.update)
object.object.update();
});
}, Time.refresh);
var draw = function () {
window.requestAnimationFrame(function () {
foreach(objects, function (object) {
foreach(FunctionObject.objects, function (object) {
if (object.draw && object.object.draw) {
object.object.draw(true);
}
Expand Down

0 comments on commit 1b7fda5

Please sign in to comment.