Get initial dock state?

With the dock and undock events I can track when the crank is docked and undocked and change the game's behaviour accordingly, but is there a way I can know whether the cranked is docked or undocked when the game is launched?

1 Like

This API should answer that: Inside Playdate

Thanks for the link, that's the answer if you're using the SDK. Sorry if it wasn't clear but I'm asking specifically in Pulp.

The dock and undock events seem somewhat limited if the initial dock state isn't known. They can be used to do something for the event, like play a sound (and maybe that is all they are intended for!), but they can't really be used for changing some game state (like swapping the player sprite) depending on whether the crank is docked as the game could start in the wrong state.

If I'm just missing something or there is a workaround, great! If not I might suggest either one of the dock and undock events firing on game start, or a new default event member called something like docked that returns 0 or 1.

1 Like

Were you able to find a solution to this problem? I'm trying to work this out too.

This seems like a reasonable thing to be able to read.

Bumping this to tag it as a feature request. Being able to call event.docked to find out whether the crank is docked or not would be very useful for working out the initial game state on startup!

3 Likes

Seems like a reasonable request. We'll look into it.

2 Likes

Bumping with a workaround - if event.aa==0 then the crank is almost certainly docked. Not absolutely definitely, but if you just want to check it once on starting the game that's probably good enough!

1 Like