Skip to content

Commit 71833ea

Browse files
committed
added autoDraw options.... someone please update docs lol
1 parent ad8d84e commit 71833ea

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

build/anvil.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13458,6 +13458,7 @@ var Scene = /** @class */ (function () {
1345813458
* @property {boolean} fromScenePrevHadLights - Whether or not the scene that the animation is coming from had lighting enabled
1345913459
* @property {boolean} toScenePrevHadLights - Whether or not the scene that the animation is going to had lighting enabled
1346013460
* @property {boolean} start - Whether or not to start the scene manager when it is initialized (true by default)
13461+
* @property {boolean} autoDraw - Should the scene manager start drawing the scene onto the canvas (true, default), or will this be handled by the user (false)
1346113462
*
1346213463
* @example
1346313464
* ```js
@@ -13496,6 +13497,7 @@ var SceneManager = /** @class */ (function () {
1349613497
this.canvas.width = this.width;
1349713498
this.canvas.height = this.height;
1349813499
this.start = (options.start == undefined) ? true : options.start;
13500+
this.autoDraw = (options.autoDraw == undefined) ? true : options.autoDraw;
1349913501
this.scenes[initialScene.id].width = this.width;
1350013502
this.scenes[initialScene.id].height = this.height;
1350113503
this.scenes[initialScene.id].canvas = this.canvas;
@@ -13630,9 +13632,11 @@ var SceneManager = /** @class */ (function () {
1363013632
}
1363113633
this.scenes[this.activeScene].draw();
1363213634
}
13633-
window.requestAnimationFrame(function () {
13634-
_this.draw();
13635-
});
13635+
if (this.autoDraw) {
13636+
window.requestAnimationFrame(function () {
13637+
_this.draw();
13638+
});
13639+
}
1363613640
};
1363713641
return SceneManager;
1363813642
}());

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,6 +2450,7 @@ exports.Scene = Scene;
24502450
* @property {boolean} fromScenePrevHadLights - Whether or not the scene that the animation is coming from had lighting enabled
24512451
* @property {boolean} toScenePrevHadLights - Whether or not the scene that the animation is going to had lighting enabled
24522452
* @property {boolean} start - Whether or not to start the scene manager when it is initialized (true by default)
2453+
* @property {boolean} autoDraw - Should the scene manager start drawing the scene onto the canvas (true, default), or will this be handled by the user (false)
24532454
*
24542455
* @example
24552456
* ```js
@@ -2488,6 +2489,7 @@ var SceneManager = /** @class */ (function () {
24882489
this.canvas.width = this.width;
24892490
this.canvas.height = this.height;
24902491
this.start = (options.start == undefined) ? true : options.start;
2492+
this.autoDraw = (options.autoDraw == undefined) ? true : options.autoDraw;
24912493
this.scenes[initialScene.id].width = this.width;
24922494
this.scenes[initialScene.id].height = this.height;
24932495
this.scenes[initialScene.id].canvas = this.canvas;
@@ -2622,9 +2624,11 @@ var SceneManager = /** @class */ (function () {
26222624
}
26232625
this.scenes[this.activeScene].draw();
26242626
}
2625-
window.requestAnimationFrame(function () {
2626-
_this.draw();
2627-
});
2627+
if (this.autoDraw) {
2628+
window.requestAnimationFrame(function () {
2629+
_this.draw();
2630+
});
2631+
}
26282632
};
26292633
return SceneManager;
26302634
}());

index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ interface SpriteOptions extends GameObjectOptions {
264264
* @property {number} width - Width of canvas (this will overwrite the canvas width)
265265
* @property {number} height - Height of canvas (this will overwrite the canvas height)
266266
* @property {boolean} [start=true] - Whether or not to start drawing the scene when the SceneManager is created
267+
* @property {boolean} [autoDraw=true] - Start drawing over and over automatically if start is true or if the draw method was called.
267268
* @example
268269
* ```js
269270
* const options: SceneManagerOptions = {
@@ -280,6 +281,7 @@ interface SceneManagerOptions {
280281
width: number; // Width of canvas (this will overwrite the canvas width)
281282
height: number; // Height of canvas (this will overwrite the canvas height),
282283
start?: boolean; // Whether or not to start drawing the scene when the SceneManager is created. True by default
284+
autoDraw?: boolean;
283285
}
284286

285287

@@ -3298,6 +3300,7 @@ Please make sure to add the objects to the scene before enabling collisions betw
32983300
* @property {boolean} fromScenePrevHadLights - Whether or not the scene that the animation is coming from had lighting enabled
32993301
* @property {boolean} toScenePrevHadLights - Whether or not the scene that the animation is going to had lighting enabled
33003302
* @property {boolean} start - Whether or not to start the scene manager when it is initialized (true by default)
3303+
* @property {boolean} autoDraw - Should the scene manager start drawing the scene onto the canvas (true, default), or will this be handled by the user (false)
33013304
*
33023305
* @example
33033306
* ```js
@@ -3333,6 +3336,7 @@ class SceneManager {
33333336
toScenePrevHadLights!: boolean;
33343337
animationRunning: boolean;
33353338
start: boolean;
3339+
autoDraw: boolean;
33363340

33373341
/**
33383342
*
@@ -3352,7 +3356,7 @@ class SceneManager {
33523356
this.canvas.width = this.width;
33533357
this.canvas.height = this.height;
33543358
this.start = (options.start == undefined) ? true : options.start;
3355-
3359+
this.autoDraw = (options.autoDraw == undefined) ? true : options.autoDraw;
33563360
this.scenes[initialScene.id].width = this.width;
33573361
this.scenes[initialScene.id].height = this.height;
33583362
this.scenes[initialScene.id].canvas = this.canvas;
@@ -3497,9 +3501,11 @@ class SceneManager {
34973501
}
34983502
this.scenes[this.activeScene].draw();
34993503
}
3500-
window.requestAnimationFrame(() => {
3501-
this.draw();
3502-
})
3504+
if(this.autoDraw){
3505+
window.requestAnimationFrame(() => {
3506+
this.draw();
3507+
})
3508+
}
35033509
}
35043510
}
35053511
/**

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
"@types/node": "^20.10.6",
2424
"@types/socket.io-client": "^3.0.0",
2525
"typedoc": "^0.25.6",
26-
"typedoc-plugin-pages": "^1.1.0"
26+
"typedoc-plugin-pages": "^1.1.0",
27+
"typedoc-material-theme": "^1.0.2",
28+
"typedoc-plugin-mdn-links": "^3.1.10",
29+
"uglify-js": "^3.17.4",
30+
"express": "^4.18.2"
2731
},
2832
"dependencies": {
2933
"canvas": "^2.11.2",
30-
"express": "^4.18.2",
3134
"fs": "^0.0.1-security",
3235
"matter-js": "^0.19.0",
33-
"socket.io": "^4.7.2",
34-
"typedoc-material-theme": "^1.0.2",
35-
"typedoc-plugin-mdn-links": "^3.1.10",
36-
"uglify-js": "^3.17.4"
36+
"socket.io": "^4.7.2"
3737
}
3838
}

0 commit comments

Comments
 (0)