How I resolved these issues:
- Animation set up
Save the Gif and convert to png files. Then, using "loadAnimation" to insert each single png file.
- Animation speed up
In the setup function, creating the new Group() and use ".addAni" to add ("random name", the variable that I store the loadAnimation);
In the draw function, write the code like:
if (random() > 0.995) {
let new_Gooma = new GoomaMonster.Sprite(width, height-100, 100, 100);
new_Gooma.scale = 0.3;
}
- Spining issue
Instead of using the collision, I use the overlap.
- How to kills Gooma
Considering to create another condition when mario overlap with Gooma, like:
if (mario.overlap(GoomaMonster[i])) {
// if (mario.overlap(GoomaMonster[i], {preventOverlap: true})) {
// check if the player is jumping
if (mario.position.y < height-90) {
// the player is jumping, remove the monster
GoomaMonster[i].remove();
score = score + 1;
} else {
// the player is not jumping, end the game
endGame();
}
} else {
GoomaMonster[i].position.x -= 0.5;
}
}
- Bullet issue
I find out the Push() will cause this problem. So I set up the bullet.velocity.x; bullet.velocity.y; bullet.position.y before push the bullets
- Moving issue
I addEventListener with ‘keydown':
document.addEventListener('keydown', function(event) {
if (event.key === 'a') {
mario.velocity.x = -10;
}
if (event.key === 'd') {
mario.velocity.x = 1;
}
});