This post applies to OpenSpace 1.x, but may apply also to 2.x (I didn’t study it yet!).
One major issue for OS1 owners is controlling avatar’s movements all the time long. Full control over the avatar. All the methods and properties related to avatar movement and re-creation of the tile-map according to new settings are private, closed. You can’t access and modify them unless you purchase a source license.
But here we go with a custom solution, which may be helpful for you in some situations as it was for us. As there is no available method to prevent avatar movement (ie, the user clicks in a tile and the avatar walks there in despite of what you say), the only solution is preventing user clicks!
Simple, not smart, but working solution.
And how in hell you do that? Also simple: place a transparent-clickable movie-clip in the tile, so it catches user clicks and nulls them. Just iterate over OpenSpace.getChildAt(0)’s children (the tiles) and do the job.
And now a few hints, as the situations are very different depending on your needs…
You can’t moveMyAvatar() or teleportMyAvatar() to the current tile –> this way you can’t prevent avatar movements! So, before user clicks, you must evaluate and decide if the avatar can walk (click, if you use the suggested workaround).
If you can’t decide prior to user’s election if he can walk/click, then you must evaluate after he clicks and starts walking. In that situation, take into consideration the previous paragraph. As you can’t moveMyAvatar() or teleportMyAvatar() to the current avatar’s coordinates (as coming from getCurrentTile()), move or teleport the avatar to a different tile.
There is a variety of events you can use to evaluate your conditions (ENTER_TILE, TILE_SELECTED, etc.), so most probably you will find some solution to your headache 😉
EDIT: Appart from the exposed method, still valid, would be nice to take a look to the following approach: dispatch a first moveMyAvatar() to a fake tile, so OpenSpace registers as current-tile the next one in the pathfinding, the issue a new moveMyAvatar() to the current (real) one.