But I’m just adding spritesheets to them, and as you can see they’re static in the air …
I want them to have movement… and collision with the ground just like my player has it.
Your right, I was doing it wrong!
But that means if I add 10 or more enemies on the map, and I want them to move, shoot against my player, how am I going to work with each enemy? Knowing that I don’t even know how to make movement for them, let alone make them shoot.
The only thing so far I did right, was creating the map correctly, and make my player move and shoot
With a phaser group. Maybe you even have an id you can pass to each enemy?
let enemiesGroup = this.add.group()
this.map
.filterObjects('objects', (object) => object.type === 'enemy')
.forEach((enemy) => {
let enemySprite = this.physics.add.sprite(enemy.x, enemy.y, 'enemy')
enemySprite.id = enemy.id // I don't know if you have some sort of id you can pass here
enemiesGroup.add(enemySprite)
})
this.physics.add.collider(enemiesGroup, ground)
That was the first example I made to better understand the phaser, but to be honest, it is not a simple example of colliding the map, adding a player, adding stars that a person will understand / know everything about the game at first. Also, I can say that I think it’s absolutely stupid, devs are always launching new versions of the phaser, and we’re already on 3.16 when they still have only phaser 2 examples on the website.
During the development of my game I always had to see other games on the web that use phaser 3, and found only 35% of information that I can use to work on my game… Or ask questions about my problems I’m having on this forum and communities and pray to god someone helps me.
But taking back what you said I’m getting the objects all inside enemiesGroup, but for some reason I’m not able to access this same variable in the update function, says it’s not defined… such as, I do not know how to add movement to these enemies …
I once started to make Phaser 3 video tutorials, but I had not time to really get into it yet. I posted the links in topic #1690. You will see how to use this in my videos.