Walls

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

taddle
Posts: 11
Joined: 25 Mar 2012, 18:14

Walls

Postby taddle » 25 Mar 2012, 18:57

I'm making a multiplayer game based on avatarChat.fla and I have a problem. I need to be able to stop users from walking on walls and the chat bar etc, but I can't use this method: http://bit.ly/sfsnowalkonfalls because the movie clip is in the way of the speech bubbles, can I re arrange this, or is there a method I'm missing?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Walls

Postby rjgtav » 26 Mar 2012, 21:54

Hello. Well, the only way is that one described on that website. Now you only need to play with the depths/layers to fit your own needs.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
taddle
Posts: 11
Joined: 25 Mar 2012, 18:14

Re: Walls

Postby taddle » 27 Mar 2012, 18:42

Thanks. My other question is, my game is based upon avatarChat, is there a way I can set where people are standing everytime they press a button, so for example, I have a button for every door, when somebody clicks that door, it changes room and frame in the chatbox movieclip, can I change the users location on the stage by changing their X and Y variable and moving their avatar?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Walls

Postby rjgtav » 27 Mar 2012, 21:53

Of course you can. You just execute the function that tweens the avatar to the new position (check the mouse listener code on the avatar chat, as it shows how to translate the character to the position where you clicked), and then you just update your UserVariables to the new position. If you want to move the avatar instantly to the new position, then you simply do myAvatar.x = blabla and myAvatar.y = blabla, and don't need to use the tween. In both cases, you need to update your UserVariables.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
taddle
Posts: 11
Joined: 25 Mar 2012, 18:14

Re: Walls

Postby taddle » 01 Apr 2012, 08:10

Okay. Thanks for the info. I haven't managed to layer things properly to make the ground work, but I'm sure I'll find a way. So as for changing the variables and moving the avatarmc, the variable part is easy, but I don't quite understand how to move the character on the screen. If I just change the variable, will the server pick that up and send data telling the screen the user has moved, and the client move it? If not, how would I get the character to move on the person's screen, it's obvious for the other players, just send info to the server, the server will deal with the rest, but how does the movement on the screen of the player who moves work? Is it like either of these:?
Player clicks on screen > Variable changes, goes to server > server sends movement back to player, and avatarChat knows what to do
or
Player clicks > server told > Moves using some actionscript directly
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Walls

Postby rjgtav » 01 Apr 2012, 12:06

This is what you should do (which is AvatarChat's way):
1. User clicks on screen and its avatar starts moving.
2. Client sends new position (which is the mouse position), by setting it as an UserVariable, for example
3. Other clients receive this new position, and start moving the user's avatar to that desired position.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
taddle
Posts: 11
Joined: 25 Mar 2012, 18:14

Re: Walls

Postby taddle » 01 Apr 2012, 17:51

Okay, I fixed the walls, I did it reverse, so the sky is not walkable and set it so it doesn't use the hand cursor. I still don't understand how I'd go around changing the location when I enter a room. What actionscript would I use on the button.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Walls

Postby rjgtav » 01 Apr 2012, 19:27

You just need to change the position of the avatar and then update the user variables... Something like:

myAvatar._x = myXValue;
myAvatar._y = myYValue;
smartfox.setUserVariables({px:myAvatar._x, py:myAvatar._y, init:false});
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
taddle
Posts: 11
Joined: 25 Mar 2012, 18:14

Re: Walls

Postby taddle » 16 May 2012, 17:17

rjgtav wrote:You just need to change the position of the avatar and then update the user variables... Something like:

myAvatar._x = myXValue;
myAvatar._y = myYValue;
smartfox.setUserVariables({px:myAvatar._x, py:myAvatar._y, init:false});

Errr, I can't seem to do that :P

Could you please put that in to a button code and set the position to 50,50 on the screen, I'll change it myself
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Walls

Postby rjgtav » 16 May 2012, 19:51

Code: Select all

on(release) = function(){
_root.myAvatar._x = 50;
_root.myAvatar._y = 50;
_root.smartfox.setUserVariables({px:_root.myAvatar._x, py:_root.myAvatar._y, init:false});
}

Important note: I don't work with AS2.0 for some years, so I'm not sure whether that code is right or not. Please check the examples and kindly read and understand them.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
taddle
Posts: 11
Joined: 25 Mar 2012, 18:14

Re: Walls

Postby taddle » 03 Jun 2012, 16:00

rjgtav wrote:

Code: Select all

on(release) = function(){
_root.myAvatar._x = 50;
_root.myAvatar._y = 50;
_root.smartfox.setUserVariables({px:_root.myAvatar._x, py:_root.myAvatar._y, init:false});
}

Important note: I don't work with AS2.0 for some years, so I'm not sure whether that code is right or not. Please check the examples and kindly read and understand them.

Okay, thanks!

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 72 guests