Building a MMO

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

Moderators: Lapo, Bax

User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Building a MMO

Postby rjgtav » 06 Jun 2009, 18:54

Hi there again. I have a problem making the movement of the character. I want to make that in the client, the character is always in the center (like pokemon) and the other clients see the player moving when it moves. Please someone help me. thank you.
m-productions
Posts: 7
Joined: 02 Jun 2009, 22:33

Postby m-productions » 07 Jun 2009, 03:42

Basically on the client side, youll want the clients "hero"character to move, BUT move the MC that the hero is in, in the opposite direction that the hero just moved, this will keep the hero in the same place (aka the middle) but the other characters will move around where they should.

Now are you having trouble sending the movement to other clients, or just wondering how to keep the "main" guy in the center?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 07 Jun 2009, 06:42

i want to send the movement to the server. i already read the docs but i don't understand much.
m-productions
Posts: 7
Joined: 02 Jun 2009, 22:33

Postby m-productions » 08 Jun 2009, 21:40

http://www.smartfoxserver.com/docs/

Check out section 5.6, thats where its all at.
I am actually working on my own tutorial for people who want to get straight to making a simple game (and skip some of the "chat" sections that the docs build on) However, section 5.6 has the basic idea of movement, when you move, you need to change that useres uservars, and then make the other clients pick up that update, and move the character to the right location.
User avatar
Lapo
Site Admin
Posts: 21012
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 09 Jun 2009, 14:27

Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 09 Jun 2009, 18:39

Ty for the help. i'm already understanding a little of the script but i have some problems.
If i put when the mouse is down, the character moves, it works bu when i put when i press a key, the character moves, the character doent's move
I want to do that when the key is down, the other clients see the character moves and the animation of moving.
can anyone help me?

This is my code:

Code: Select all

function walk(horizontal,vertical){
   avatarMC._x += horizontal;
   avatarMC._y += vertical;
   if (inited)
   {
      if (!_global.isBusy)
      {
         var px:Number = int(avatarMC._x)
         var py:Number = int(avatarMC._y)
         
         
         
         if ((px > avatarW/2) && (px < areaW - avatarW/2) && (py > avatarH/2) && (py < areaH - avatarH/2))
         {
            // save new variables
            // Please note that init is set to false:
            // this means that we're only moving somewhere and we don't need to init tha avatar
            smartfox.setUserVariables({px:px, py:py, init:false})
            
            // method derived from the [flashAPI].as
            // moves the mc using the "Quint" equation, with "InOut" easying
            // to the new px,py position in 100 milliseconds.
         }
      }      
   }
}

if(Key.isDown(Key.RIGHT)){
   _root.walk(5,0);
}

if(Key.isDown(Key.LEFT)){
   _root.walk(-5,0);
}
myMouse.onMouseDown = function()
{
   _root.walk(0,-5);
}
if(Key.isDown(Key.DOWN)){
   _root.walk(0,5);
}

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 3 guests