Sorry for such a basic question, but I'm struggling to figure out how to make my player change direction as it moves.
I've created four frames for the player facing the cardinal directions, and have set the fps to 0 so it's not constantly spinning, but I'm not sure where to go from here. There's no function I can see for "on {arrow press}", so I'm not sure how to tell pulp to respond to directional buttons being pressed and change the frame accordingly to the proper direction.
In the players on update do function you need some if statements to check event.dx.
// face left
if event.dx==-1 then
//do something like a tile swap.
// face right
elseif event.dx==1 then
//do another tile swap, function or whatever
end
end
"dx" is a predefined check for "direction x" inside the event call. It's only ever 1 or -1
Use the event.dy and event.dx Values to determine what button was pressed by the player. Will be either positive or negative 1 depending on if up/down/left/right was pressed on the d-pad.
That helps, thank you! I didn't realise I needed to use different tiles for the player rather than asking Pulp to call a different frame. That probably is possible, but I don't know how and this works just fine!
You can def set different frames for the player rather than swapping tiles. Just depends on whether or not you want to animate your player as it faces different directions or just show a static image.
If you're going the route of showing a static frame for each direction, you can just use a single player tile with the FPS set to 0. Then, instead of swapping the tile, call frame [frame #] from the player script to display a different frame (note that it's a 0-based index).