Hi.
I began yesterday with looking into phaser, and I got a couple of questions. It would be great if anybody could give me some advice.
-
Performance. Is great for me everywhere, except for Chrome (Version 71.0.3578.98) on my MacBook. On any other browser on the MacBook things work well, also on my Android phone and on my Windows PC. The Chrome on my old Android phone has a far better performance than the Chrome on my MacBook. The problem seems to show up with any Phaser3 application making use of matter.js (all matter js examples for phaser3 were slow, other examples (like arcade physics) went smoothly). Is that a known problem? Is there a fix?
-
I’m writing some functions that have "sparks (small glowing objects) appear when two objects collide. So far that works, I get sparks spawning and flying around when the objects hit each other. However, the sparks are not spawning at the correct location, I assume because matter considers that location already as being taken up by the colliding objects, so it spawns the sparks someplace else. What would the best way be to fix that? To me, it seems that it would be best to have the sparks not check collision with those two objects or with each other. Can I somehow tell matter js to have the sparks ignore certain other objects regarding collisions?
-
I want the sparks to shrink and then vanish. So I put all the spark objects in an array and iterate through it (sorry, didn’t find here code tags):
function update() {
for(var i = 0; i < particles.length; i++) {
var scale = particles[i].scaleX;
if(scale < 0.5) {
//remove spark
}
else {
particles[i].setScale(scale - 0.01);
}
}
}
Basically, each object in the particles array is having it’s scale reduced until the scale is smaller than 0.5 at which point nothing happens right now (it’s ignored). The problem is that crashes the app. It runs for a second, and then the tab doesn’t react anymore (I don’t know if it’s caught in a loop or crashes or something).
I don’t know where the problem is. If I set the scale to a fixed amount in the “setScale” line, then that works. But if it depends on the last scale setting, it crashes quickly. I thought that at some point maybe the “scale” variable contains something that’s not a number, if something is not found, but that doesn’t make any sense and when creating an output the values always seemed to be correct. Any help?
- How do I delete an object in a phaser3 matter world? I think the last attempt was something like: this.world.remove(particles[i]) or this.matter.remove() or something like that (I will put in here the correct code I used, currently having no access to it) to remove a certain particle object (and splicing it from the array). Doesn’t work. I don’t get an error message. The correct object is targeted and it’s not moved anymore, so somewhere it was removed, but it’s still visible on the screen. Do I have to refresh it?
Thanks for any help.