We're working on a game with OpenSpace that needs to do two things:
1. When two avatars stop on the same tile, a custom event happens that we define.
2. When the user rolls over another avatar, a pop-up menu that we create reveals information about that avatar.
To accomplish both of these tasks, we need some way for each player to have access to a list of all of the avatars in the room. I know that we can use events such as EnterTile to track an avatar's change in position, but we need the player to immediately know who all other avatars in the room are when he or she first enters the room.
Is there any way to generate such a list upon entering a room? Any suggestions would be welcome.
Thank you.
Get list of all avatars in room when entering
-
- Posts: 7
- Joined: 28 Jan 2009, 18:22
-
- Posts: 7
- Joined: 28 Jan 2009, 18:22
Please check the SmartFoxServer documentation, in particular theclient-side API: you will find the getUserList method on the Room object.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 7
- Joined: 28 Jan 2009, 18:22
This has been extremely useful so far. Similar to this thread, I need to get the positions of all of the avatars in the room when I first enter the room. Using your advice here and the (undocumented) getAvatarMovieClipById() method described in the other thread, I've written this function, which gets called from the onAvatarMovementEnd event handler:
Unfortunately, running the code gives me this error:
Now, I'm not clear on whether getAvatarMovieClipById is a static method or not. If I make a non-static call to the method, I get a similar error:
produces
I'm using the trial version of OpenSpace, and the os compiled clip that comes with the trial version is my OpenSpace instance.
Any help would be appreciated. Thanks.
Code: Select all
function collisionTest():void
{
//Get the tile I'm on
var myTile:Tile = os.getCurrentTile();
//Get the room
var thisRoom:Room = smartFox.getActiveRoom();
//Get the users in this room
var users:Array = thisRoom.getUserList();
//Test the other avatars to see if they're on the same tile
for (var u:String in users)
{
var uid:int = users[u].getID();
var thisAv:MovieClip = OpenSpace.getAvatarMovieClipById(uid);
//..more to come
}
}
Unfortunately, running the code gives me this error:
Code: Select all
1061: Call to a possibly undefined method getAvatarMovieClipById through a reference with static type Class.
Now, I'm not clear on whether getAvatarMovieClipById is a static method or not. If I make a non-static call to the method, I get a similar error:
Code: Select all
var thisAv:MovieClip = os.getAvatarMovieClipById(uid);
produces
Code: Select all
1061: Call to a possibly undefined method getAvatarMovieClipById through a reference with static type com.smartfoxserver.openspace:OpenSpace.
I'm using the trial version of OpenSpace, and the os compiled clip that comes with the trial version is my OpenSpace instance.
Any help would be appreciated. Thanks.
-
- Posts: 7
- Joined: 28 Jan 2009, 18:22
Hmmm...No, I just tried it again with the os and received the same error:
It's interesting that an earlier line in the same function that also references the compiled clip
doesn't have a problem. Is it possible that my version of the os compiled clip doesn't contain the getAvatarMovieClipById method?
It's Flash, so I'm not really sure how I could be recompiling the file incorrectly. I'll keep playing around with it on my end, but I'd welcome any additional suggestions.
Thanks.
Code: Select all
1061: Call to a possibly undefined method getAvatarMovieClipById through a reference with static type com.smartfoxserver.openspace:OpenSpace.
It's interesting that an earlier line in the same function that also references the compiled clip
Code: Select all
var myTile:Tile = os.getCurrentTile();
doesn't have a problem. Is it possible that my version of the os compiled clip doesn't contain the getAvatarMovieClipById method?
It's Flash, so I'm not really sure how I could be recompiling the file incorrectly. I'll keep playing around with it on my end, but I'd welcome any additional suggestions.
Thanks.
-
- Posts: 7
- Joined: 28 Jan 2009, 18:22
I just did a fresh download of the OpenSpace v1 trial from the website. In both the FarWest_Ranch and the Slopes examples, I added this line of code in the onOpenSpaceInitialized event handler, right before the call to os.loadMap():
Both examples produced the same 1061 error message that my project was giving me. Is it possible that there's something else on my end that's causing the problem? Please let me know.
Thanks.
Code: Select all
os.getAvatarMovieClipById(3);
Both examples produced the same 1061 error message that my project was giving me. Is it possible that there's something else on my end that's causing the problem? Please let me know.
Thanks.
I guess the problem might be in the trial version: that method you are using was added later, as requested by one of our customers, and probably we added it to the retail version only. Sorry, this didn't come to my mind before (also I thought you were using the retail version).
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 7
- Joined: 28 Jan 2009, 18:22
Return to “OpenSpace v1 discussions and help”
Who is online
Users browsing this forum: No registered users and 29 guests