I want my players to become a different player after interacting with an Sprites or Items, and after this player can only move along a designated path by relying on a crank. However, I really don't know how to implement this. Plz help me out.
Hi i didn't get what you wanted to do with the crank thought for changing the player character on interact on the other object
On the other object script solid :
on interact do
tell event.player to
swap "anytile"
end
end
but it depend if you use draw function for already drawing your character...
In that case you should
On the other object script solid :
on interact do
myTilePlayerName= "anytile"
end
in enter of player :
on enter do
// make it useable anytime when player enter in any tile script (like a global variable)
myTilePlayerName="mybeginplayertile"
end
In draw of player :
on draw do
swap myTilePlayerName
end
Should work for that
Thanks for your help. And about crank, I want to make players can use the crank to move forwards and backwards along a set path.
Hello!
To make the player move with the crank, you use event.ra
to tell if the crank is moving clockwise or counterclockwise. If you want to make the player go up and down, change the conditionals from PX
to PY
.
on crank do
//get the player's current direction
PX = event.px
PY = event.py
//if the crank is moving clockwise, then move forward, and if it's moving counterclockwise, move backward.
if event.ra > 0 then
PX++
elseif event.ra < 0 then
PX--
end
goto PX,PY
end
One extra thing - it's a bit trickier to stop the player sprite from moving when the D-Pad is pressed, if that's what you're trying to do. There are some possible answers in this thread: Player Pre-Movement Event - #9 by jickup
Otherwise, you could hide the player sprite and manually draw a player-like tile in the right place, updated by the "on crank" event, I think. But it might depend on what your screen setup is like and what functionality you need in general.