No scrolling maps in OpenSpace

Seems this is a FAQ for many OpenSpace users and it has been answered many times in their support forums. There isn’t support for no-scrollable maps in version 1.x of OpenSpace and it has been announced as a new feature for the incoming version 2.

In the mean time, while in the middle of the development of qilania, we found a workaround. Basically, you must attach the AvatarEvent “AVATAR_CREATED”, then call the method “centerViewOnTile”. You must make sure, though, that it exists a tile in the related position, so SmartFox/OpenSpace can find it using the z-index, which seems a requirement for “centerViewOnTile” to work. Sample code:

// os is the instance of the OpenSpace component in the stage
os.addEventListener(AvatarEvent.AVATAR_CREATED, onAvatarCreated)

function onAvatarCreated(evt:AvatarEvent):void {
	var pos:Object  = {px: 12, py: 12, pz:0};
	os.centerViewOnTile(pos);
}

You can know which tile you wish the viewport centered-in just making rollover in the map editor of the OpenSpace Editor. As stated, make sure there is a tile in such position of the tilegrid (being walkable or no walkable) by looking for the “z” property (close to x and y).

Appart from this, we created a background which must fit in the tilegrid (so, be smaller than the grid).

You must know as well that some actions of the avatar, such as teleportation, will fire “centerViewOnMyAvatar” (which will move the viewport), so immediately after the teleportation you must use again the “centerViewOnTile” method.

Most probably it would do the trick using a zoomed map (documentation says that using zoom will disable map auto-scrolling), but that would make the development process (basically illustration) a bit more complicated than it is already.

But there are more workarounds for sure, and you can find various in the support forums of OpenSpace.