- API usage
- best practices
- codding standards
Very smooth. I like it. Level 3 is already very hard
As for coding, maybe add some comments, and try to keep your files small. GameScene.js has a lot going on, easy to lose the overview…
After seeing your code, there are two things that in my humble opinion could be improved (GameScene.js):
this.cursors = this.input.keyboard.createCursorKeys();
In more complex games these changes would be more relevant.
Congratulations for your first game with Phaser !! .
I tried to refactor my code to use pools/groups for my gameobjects. But I can not make it behave the same way as it does when I still used .destroy(). In stead of destroy I now use:
But the other active aliens will still bumb into the old one and don’t move properly. So I tried moving them offScreen:
But now they end up in the bottom corner and still get velocity when I call group.setVelocityX(20);
So what is the best way to replace the alien.destroy() call then using pools?
The aliens group elements have a body, so you should use disableBody :
alien.disableBody (true, true);
This is equivalent to:
alien.body.enable = false; alien.setActive (false); alien.setVisible (false);
For the same reason, setPosition() produces unexpected results. An appropriate method would be body.reset:
alien.body.reset (x, y);
Good luck !!