我正在使用SmartFoxServer Pro进行游戏,但我遇到了问题。当用户点击我在主房间的一扇门并更换房间时,他的速度会增加!这是我的代码: 点击移动代码:
var myMouse:Object = {}
Key.addListener(keyListener);
myMouse.onMouseDown = function()
{
if (inited)
{
if (!_global.isBusy)
{
var px:Number = int(avatarMC._xmouse)
var py:Number = int(avatarMC._ymouse)
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.
myAvatar.easingTo("Quint", "InOut", px, py, 100)
}
}
}
}
加入房间代码:
smartfox.onJoinRoom = function(roomObj:Object)
{
serverOut.name = _global.myName
serverOut.sendAndLoad("clothing.php", serverIn, "post")
serverOutd.name = _global.myName
serverOutd.sendAndLoad("rank.php", serverInd, "post")
if (!bListLoaded) {
bListLoaded = true;
_root.smartfox.loadBuddyList();
}
cleanAvatars()
var roomId:Number = roomObj.getId()
var userList:Object = roomObj.getUserList()
resetRoomSelected(roomId)
_global.currentRoom = roomObj
// Update Room Name in the avatar area
currentRoom.htmlText = "Current room: <b>" + roomObj.getName() + "</b>"
// Clear current list
userList_lb.removeAll()
for (var i:String in userList)
{
var user:User = userList[i]
var uName:String = user.getName()
var uId:Number = user.getId()
userList_lb.addItem(uName, uId)
if (uName != _global.myName)
{
var uVars:Object = user.getVariables()
var mc:MovieClip = avatarMC.attachMovie("avatar", "avatar_" + uId, Number(uId))
mc._x = uVars.px
mc._y = uVars.py
mc.disc.gotoAndStop(uVars.col)
mc.name.textColor = uVars.rank
mc.name.text = uName
}
}
// Sort names
userList_lb.sortItemsBy("label", "ASC")
setupMyAvatar()
}
更改碰撞代码的空间:
onClipEvent (enterFrame) {
if (this, hitTest(_root.chatBox.entershop)) {
_root.chatBox.gotoAndPlay(2);
//_root.gotoAndStop(17);
_root.smartfox.joinRoom("The Kitchen");
//_root.smartfox.setUserVariables({px:"377", py:"175"})
}
}
如何阻止用户每次加入房间时加快速度?请帮忙!