I'm having an issue making this conditional statement work successfully.
I want to take off "-10" from the height for "Event 3", a sprite on my map, and have managed to do that successfully. But what I'm struggling with is successfully making every other Event on the map have "+10".
The code below works in that it takes -10 from the height of $gameMap.event(3) like I want, but all the other Events also have -10 for some reason, instead of +10.
var ev3 = $gameMap.event(3);
if (ev3) {
x = ev3.screenX();
y = ev3.screenY();
y -= ev3.spriteHeight()-10;
} else {
var ev = $gameMap.event(eventId);
if (ev) {
x = ev.screenX();
y = ev.screenY();
y -= ev.spriteHeight()+10;
}
}
I definitely have done something wrong in this code as the -10 is only meant to be specifically for $gameMap.event(3).
I'm a bit embarrassed as I'm assuming this will be a very easy thing to solve, and I'd love to figure out where I went wrong so a code noob like me can learn from this for next time. Thanks in advance to anyone who is kind enough to help me.
Aucun commentaire:
Enregistrer un commentaire