Like when u click somewhere the avatar goes there.
But i wanna make it so that the avatar cannot walk on buildings or the sky...
I know this is really off topic or hasn't got anything to do with sfs But i really need help
pls help!
Code: Select all
if( !UNWALKABLE.hitTestPoint(e.stageX, e.stageY) ){
//Tell smartfoxserver to move the avatar
}Didn't work for meext0sus wrote:This isn't a very secure method. Ideally you would want to check if the destination is walkable from the server side but if you're not bothered about people "hacking" your game to move where they want, you can use hitTestPoint to stop the client from ever requesting to move their avatar:
Inside your mouse click handler:Where 'UNWALKABLE' is the instance name of the movieClip containing anything you don't want the player to walk on.Code: Select all
if( !UNWALKABLE.hitTestPoint(e.stageX, e.stageY) ){ //Tell smartfoxserver to move the avatar }
This post assumes you're using AS3 and an art-based map/level.
Hey, I was wondering can this code with in AS2? If not is there a HitTest code like this for AS2? also where it says e.stage do I put the dimensions of where i don't want the avatar to walk?ext0sus wrote:This isn't a very secure method. Ideally you would want to check if the destination is walkable from the server side but if you're not bothered about people "hacking" your game to move where they want, you can use hitTestPoint to stop the client from ever requesting to move their avatar:
Inside your mouse click handler:Where 'UNWALKABLE' is the instance name of the movieClip containing anything you don't want the player to walk on.Code: Select all
if( !UNWALKABLE.hitTestPoint(e.stageX, e.stageY) ){ //Tell smartfoxserver to move the avatar }
This post assumes you're using AS3 and an art-based map/level.
There is a hitTest function for AS2. Just Google "AS2 hitTest" and you'll find a lot of information about it.skybucks100 wrote:Hey, I was wondering can this code with in AS2? If not is there a HitTest code like this for AS2? also where it says e.stage do I put the dimensions of where i don't want the avatar to walk?ext0sus wrote:This isn't a very secure method. Ideally you would want to check if the destination is walkable from the server side but if you're not bothered about people "hacking" your game to move where they want, you can use hitTestPoint to stop the client from ever requesting to move their avatar:
Inside your mouse click handler:Where 'UNWALKABLE' is the instance name of the movieClip containing anything you don't want the player to walk on.Code: Select all
if( !UNWALKABLE.hitTestPoint(e.stageX, e.stageY) ){ //Tell smartfoxserver to move the avatar }
This post assumes you're using AS3 and an art-based map/level.
Thanks!
Yep I googled it and the first link was a Adobe Flash one from Adobe if anyone else was looking for the code this is what i found:ext0sus wrote:There is a hitTest function for AS2. Just Google "AS2 hitTest" and you'll find a lot of information about it.skybucks100 wrote:Hey, I was wondering can this code with in AS2? If not is there a HitTest code like this for AS2? also where it says e.stage do I put the dimensions of where i don't want the avatar to walk?ext0sus wrote:This isn't a very secure method. Ideally you would want to check if the destination is walkable from the server side but if you're not bothered about people "hacking" your game to move where they want, you can use hitTestPoint to stop the client from ever requesting to move their avatar:
Inside your mouse click handler:Where 'UNWALKABLE' is the instance name of the movieClip containing anything you don't want the player to walk on.Code: Select all
if( !UNWALKABLE.hitTestPoint(e.stageX, e.stageY) ){ //Tell smartfoxserver to move the avatar }
This post assumes you're using AS3 and an art-based map/level.
Thanks!
But Carl Lydon is right, it's much better to use a tile-based system. Having your map arranged into tiles has a lot of advantages including being easier to program AI and check collisions on the server side.
There are lots of other advantages but it would take me a while to list them.