Flash 当光标静止时,MouseX值会发生变化
这是我的密码:Flash 当光标静止时,MouseX值会发生变化,flash,actionscript-3,actionscript,flash-cs5,Flash,Actionscript 3,Actionscript,Flash Cs5,这是我的密码: public function update() { //making the character follow the mouse if(mouseX > (x + 25)) { //if the mouse is to the right of mcMain x += mainSpeed;//move mcMain to the right } else if
public function update()
{
//making the character follow the mouse
if(mouseX > (x + 25))
{ //if the mouse is to the right of mcMain
x += mainSpeed;//move mcMain to the right
}
else if (mouseX < (x - 25))
{//same thing with the left side
x -= mainSpeed;
}
else
{
trace(x + " and " + mouseX);
x = mouseX;//if it's close enough, then make it the same x value
}
}
mouseX没有被我更改(因为它是只读的,所以不能更改),这个对象中没有任何其他代码,因为我刚刚开始这个项目
谢谢。您的mouseX似乎基于拥有您正在设置的“x”属性的剪辑。当您不断将x设置为mouseX时,这将更改光标相对于剪辑的位置。这就是它在两个值之间振荡的原因
修复:尝试使用父剪辑获取鼠标位置,然后根据需要更改子剪辑的位置。ie:_parent.mouseX而不是mouseX您的mouseX似乎基于拥有您正在设置的“x”属性的剪辑。当您不断将x设置为mouseX时,这将更改光标相对于剪辑的位置。这就是它在两个值之间振荡的原因
修复:尝试使用父剪辑获取鼠标位置,然后根据需要更改子剪辑的位置。ie:_parent.mouseX而不是mouseX完美!非常感谢你!完美的非常感谢你!
84 and 80
80 and 84
84 and 80
80 and 84
84 and 80
80 and 84
84 and 80