Moving very slowly [AS3]

Subscribe to Moving very slowly [AS3] 7 posts

avatar for Mond Mond 749 posts
Flag Post

I have a full moon I want to move slowly across the screen. However, something like…

private function MoveMoon(e:Event):void
{
	if (!(++frameCounter % 500))
	{
		fullMoon.x += 1.0;
		fullMoon.y -= 1.0;
	}
}

provides “steppy” looking movement. Has anyone experimented with very slow movement…maybe something using masks with two Bitmaps of the full moon to work with? Or can something like GreenSock move images slowly without steppyness?

 
avatar for jasonjie88 jasonjie88 302 posts
Flag Post

Hmmm. Your code should no have your moon having ‘steppy’ movements. Unless your SWF frame speed is too slow. But what you could try doing is varying the moon speed, not so fast that the moon sometimes jumps across the screen, but enough to provide realistic movement. Say between 1-3 px per frame.

 
avatar for Shake_N_Baker Shake_N_Baker 53 posts
Flag Post

You could just reduce the size of each step and step more often, x/y values can be moved by as small as 0.05 in flash iirc.

private function MoveMoon(e:Event):void
{
	if (!(++frameCounter % 25))
	{
		fullMoon.x += 0.05;
		fullMoon.y -= 0.05;
	}
}
 
avatar for Mond Mond 749 posts
Flag Post

I tried that Shake…but Flash must be rounding the x and y registration point values to ints because the movement is still steppy. Flash may use a 0.05 accuracy internally, but when it renders the full moon still steps.

 
avatar for downdown downdown 36 posts
Flag Post

i know this isnt what you asked, but you could put the moon on a larger movieclip and have the moons parent rotate making the moon move across the sky, it may look better than chaging its x,y

 
avatar for dragon_of_celts dragon_of_celts 282 posts
Flag Post

Pixels are all at integer coordinates, so any fractional movement is rounded when applying to the screen (though whether Flash tries to do visual interpretation of fractional movement, I don’t know; but I doubt it). Since you’re only moving one pixel every 500 frames (at 30 FPS, that’s one pixel every 16.6 seconds approx. — that’s a long time between movements), the “bump” will always be noticeable when moving a static picture without effects.

If it fits with your theme, you might try a fluid fog effect (where the “fog” makes the moon look like it is rippling a bit). Otherwise, you could try blending between different moon pictures (though at that rate of movement, I think it would likely still be difficult to get the illusion of smooth movement right).

 
avatar for Mond Mond 749 posts
Flag Post

Thanks dd…I didn’t think of that.

E:dd’s ingenuity has inspired me…what about a custom anti-aliasing routine. Changing the color of the pixels in front of and behind the moon in the direction I am moving? Now that is a challenge worth coding…interesting…but I think I’ll try dd’s idea first…it’s easier!