2

I'm having trouble with smooth character movement for a 2d game I'm making. It looks like the character is double when moving. Kinda like this (its just one pixel though):

 ( ()
/ /{}\  ==>
|  ||

The game runs on a solid 60 FPS and my monitor is not the problem (I have tested this on several monitors).

I'm using starling at the moment, but I've had this since I first stared making games (using openGL). I was hoping someone could tell me what I'm missing. Here is my code:

private var _x:Number = 20, _y:Number;

public function update(delta:Number):void
{
    if(gravity){
        _y += delta * 120;
    }

    if(_y + skin.image.height > game.stage.stageHeight){
        _y = game.stage.stageHeight - skin.image.height;
        gravity = false;
    }

    if(right && left){
        skin.playAnimation("none");
    }else if(left){
        _x -= delta * speed;
        skin.playAnimation("left");
    }else if(right){
        _x += delta * speed;
        skin.playAnimation("right");
    }

    //update skin
    skin.update(delta, Math.round(_x), Math.round(_y));
}

skin update method:

    public function update(delta:Number, x:int, y:int):void
    {
        image.x = x;
        image.y = y;
        if(currentAnimation){//this is texture switching (I tried without, still happens)
            currentAnimation.update(delta);
        }else{
            image.texture = textures[4];
        }
    }

Here is the game.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Duckdoom5
  • 716
  • 7
  • 27
  • try cleaning/redrawing parent container after move – Misiakw Jan 07 '14 at 12:12
  • I guess Starling/Stage3D does that automatically. Does it? – Duckdoom5 Jan 07 '14 at 12:14
  • i've never worked with Starling/Stage3D, but that would be my first guess. Still it's worth trying to call invalidateDisplayList() ou updateDisplayList() on parent container. – Misiakw Jan 07 '14 at 12:20
  • I'll try and tell you how it goes, thx for the help though – Duckdoom5 Jan 07 '14 at 12:20
  • I've tried [stage.Invalidate()](http://stackoverflow.com/a/14733437/2811643) but that didn't work. The starling sprite has no such method though. – Duckdoom5 Jan 07 '14 at 12:42
  • Forgive the obvious nature of the question, but are you sure it's not your monitor? Try moving a white window around the screen and see if you don't have the same ghosting happening. – Atriace Jan 07 '14 at 15:02
  • Yeah, it could be, but then why does [this](http://www.newgrounds.com/portal/view/621189) game (sorry for linking) look normal and my game not ? They clearly have something that I'm missing.. :/. Though to make sure, I'll try on my desktop when I'm home. – Duckdoom5 Jan 07 '14 at 15:08
  • I made a pong game that uses the same technique as shown above, it has the same visual bug with the ball. [Here](http://www.newgrounds.com/portal/view/629284) it is. (again sorry for linking, but it just to show the problem) – Duckdoom5 Jan 07 '14 at 15:13
  • I've tried on several monitors and it looks the same so its not my monitor – Duckdoom5 Jan 08 '14 at 13:20
  • @Duckdoom5 It really looks as pixel response time problem. The other game probably looks ok because the contrast difference between moving character and the background is small, while it is quite big in your game. – Varnius Jan 10 '14 at 10:16
  • Hmm, and is there no way to fix it other then editing the color of my background? – Duckdoom5 Jan 10 '14 at 12:01
  • I agree with Atriace, it just looks like monitor ghosting to me. Your character is moving much faster than "The Gentleman" game, and the contrast between character and background is much higher. Same in pong - neon ball on black background moving pretty quickly. You could try to counter this hardware effect in software by adding a second Image that is always 1 frame behind the first (perhaps with alpha=0.2), but I'm not sure that'd really work. It'd look like motion blur, which honestly can look good for fast-moving objects - you might be happier with that visual effect. – Jeff Ward Jan 10 '14 at 17:57
  • Also, you'd likely get more bang for the buck by making the character slowly accelerate than go from 0 to moving at a constant fast speed. Check out my recent [LD28 game](http://jcward.com/ld28/) (arrow keys to move, space to jump) that's also Starling. Again, my character isn't moving as fast, but the acceleration gives a nice feel. – Jeff Ward Jan 10 '14 at 18:04
  • Just tried actual screen capture, and no, there is no texture duplication. However, my WinXP behaves oddly if I have a shadow dropped over the game area, it blinks in and out. So it's probably your monitor along with probable misbehavior of your video card drivers. – Vesper Jan 11 '14 at 03:44
  • I'm very sure it has nothing to do with my hardware, mainly because I tried it on a damn load of pc and all look the same( very good hardware to bad hardware). but I also found out that a lok of games have the same behaviour but I've never noticed it before. So, I guess I just have to live with it. – Duckdoom5 Jan 11 '14 at 15:15

2 Answers2

1

Based on my own experimentation, as well as all the data in the comments, I think the ghosting is dependent on the frame rate and the computer itself.

First, and most importantly, when I tried the game in the link, it had the described ghosting at the full frame rate of 60. However, when I tried to film a screencast for further analysis, that occupied some CPU, dropping the frame rate down to around 35 or 40. At that point, the ghosting stopped.

Second, because different people are reporting different experiences with the described ghosting, I'd also think that it has a little to do with the individual computers themselves, probably rooted in their available memory and CPU, though that's just a theory, as I don't have any benchmarks to go off of.

Third, I think part of it is also rooted in neuroscience, as different people perceive animation differently.

People always talk about wanting a higher frame rate, but honestly, to fix this, I would recommend LOWERING the frame rate. Flash Professional CS6 has a default frame rate of 24 FPS, and I have never experienced a ghosting problem to my memory. It is worth mentioning that Flash animators usually work in 24 FPS.

Then again, appearance-wise, it really isn't a major deal. It is one of those graphics flaws that people tend to ignore, similar to the motion blur you get on 24 FPS films, until they changed it to 48.

CodeMouse92
  • 6,840
  • 14
  • 73
  • 130
  • Since this is the only and best answer yet, and you've put a lot of effort in it, I'll go ahead and give you my bounty ;p I think you'r right: "It is one of those graphics flaws that people tend to ignore." Thats why I've never noticed it on other games but with my own games I try to get the best out of it. but like I said before, I guess I'm fine with it now since I've noticed how many games have the same 'problem'. – Duckdoom5 Jan 12 '14 at 00:04
  • Thanks, Duckdoom5! Yeah, more is not necessarily better, though I think programmers lean towards higher framerates because we associate larger numbers with better performance (I've noticed a number of programmers aiming for very high framerates). Animators, on the other hand, as I mentioned, like to stick to movie standard framerates: 24 and 48. One other advantage to lower framerates? Less frames needed to accomplish the same animation, thus, it is considerably easier to control speed, using frame COUNT instead of frame SPEED. – CodeMouse92 Jan 12 '14 at 00:05
  • I'll try a lower frame rate, if its not that noticable I'll keep it. – Duckdoom5 Jan 12 '14 at 00:11
0

It seems to be something that all games have (I actually never noticed it on some games where I do notice it now) and I just have to live with it. Its not my hardware, its not my monitor. I tried it on a lot of computers (good to bad hardware) and it looks the same on all computers. It looks worse on the computers with bad hardware, but there is not a huge difference.

Duckdoom5
  • 716
  • 7
  • 27