Skip to content

Commit ba8d1a3

Browse files
committed
Add Pixi.js existence check; Clean up for initial release
1 parent 09e57d2 commit ba8d1a3

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

SuperParticles.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ window.SuperParticles = window.SuperParticles || class SuperParticles {
44
if (typeof PIXI === 'undefined') {
55
throw new Error("Failed to initialize SuperParticles because Pixi.js was missing!")
66
}
7-
if (PIXI.VERSION.split('.').shift() < 5) {
7+
if (parseInt(PIXI.VERSION.split('.').shift()) < 5) {
88
console.warn("Old Pixi.js version detected. Features like FPS limiting won't be available. Switch to a version > 5.0.0-rc if possible.")
99
}
10+
/*else if (PIXI.VERSION === '5.0.0-rc') {
11+
console.warn("This exact version of Pixi.js (5.0.0-rc) is not supported because of a bug. Use a newer version please.")
12+
}*/
1013
this.defaultCfg = {
1114
useJquery: undefined, // true/false/undefined
1215
maxFps: 30, // requires pixi.js v5
@@ -186,7 +189,6 @@ window.SuperParticles = window.SuperParticles || class SuperParticles {
186189
}
187190
destroy(destroyApp=true, removeView=true, stageOptions=true, removeContainer=true, forceRemoveContainer=false, removeResizeListener=true, removeParticles=true) {
188191
if (destroyApp) {
189-
//debugger
190192
if (typeof this.app === 'object' && typeof this.app.destroy === 'function') {
191193
if (!removeParticles && typeof this.particles !== 'undefined') {
192194
for (let particle of this.particles) {
@@ -199,8 +201,6 @@ window.SuperParticles = window.SuperParticles || class SuperParticles {
199201

200202
this.linesLayer = undefined
201203
if (removeParticles && typeof this.particles !== 'undefined') {
202-
//for (let particle of this.particles) {
203-
//}
204204
//this.particles = []
205205
}
206206
this.debugOverlay = undefined
@@ -240,9 +240,7 @@ window.SuperParticles = window.SuperParticles || class SuperParticles {
240240

241241
const particlesToAdd = this.cfg.particles.amount-this.particles.length
242242
const particlesToRemove = 0-particlesToAdd
243-
if (particlesToAdd === 0) {
244-
return
245-
}
243+
246244
for (let i=0; i<particlesToAdd; i++) {
247245
const randomCoord = this._getRandomCoord()
248246
const particle = new PIXI.Graphics()
@@ -258,8 +256,6 @@ window.SuperParticles = window.SuperParticles || class SuperParticles {
258256
this.app.stage.removeChild(this.particles[0])
259257
this.particles.shift()
260258
}
261-
console.log(`Added ${particlesToAdd} particles.`)
262-
console.log(`Removed ${particlesToRemove} particles.`)
263259
}
264260
_createLinesLayer() {
265261
this.linesLayer = new PIXI.Graphics()

0 commit comments

Comments
 (0)