Below I have a simple multiplayer project with two player sprites at the top that will move to dodge snakes. I’m trying to see if it’s possible to have a single overlap event between players and enemies and if I can utilise ‘getPlayerBySprite’ in some way to get the player and use that player object to directly change that player’s lives.
so it could look something along the lines of
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function(playerSprite, enemySprite) {
// let thisPlayer be the player attached to playerSprite
// change the lives thisPlayer by -1
})
I’m aware I could do a few things like attach sprite data to the sprite representing the current player and use an if statement inside the overlap event and I could use different spriteKinds with different overlap events, I’m just scoping out other methods of approaching this.
Thanks for your time!