As hinted by someone in one of your other topics (which I can’t track down right now), the weapon lagging behind the player is probably an issue of updating/rendering order.
Ideally what you want to happen is:
- Update player position
- Update weapon position
- Render player
- Render weapon
So you should recheck your code and ensure that your weapon updating code runs after the player one (in FlashDevelop you can set some breakpoints in the relevant update()
functions and step through code from there).
(We seriously need a sticky tutorial/link for some basic/intermediate debugging with FlashDevelop, it would really help!.. in the meanwhile you can consult Google if you don’t know how to do it, or insert traces to find out what the order is)
Also… your adjust_()
functions seem to do exactly what moveBy()
in combination with moveCollide_()
do. So you could replace them with something like:
override public function update():void
{
moveBy(xSpeed, ySpeed, "ground", true);
}
override public function moveCollideX(e:Entity):Boolean
{
xSpeed = 0;
return true;
}
override public function moveCollideY(e:Entity):Boolean
{
ySpeed = 0;
return true;
}
This would basically translate to:
- Try to move player by xSpeed and ySpeed (1 pixel at a time specified by the
true
param) and watch out for collisions with “ground” - If collides horizontally with “ground”
moveCollideX()
gets called and you reset thexSpeed
- If collides vertically with “ground”
moveCollideY()
gets called and you reset theySpeed