In this case, I want it to add a vx to a sprite’s x each time to make a motion.
at first, the x value of the sprite is 254, the vx is very small, only 0.01
As there might be some trouble when dealing with float numbers, I try to “zoom” the value of vx to a bigger one by multiplies 10000
everything seems working fine except I cannot pass the new result to my x value of the sprite:
dx = someSprite.x*10000;
trace("x: "+someSprite.x+",dx: "+dx+",vx: "+someSprite.vx*10000);
dx += someSprite.vx*10000;
dx = dx/10000;
trace("x: "+someSprite.x+",dx: "+dx+",vx: "+someSprite.vx*10000);
someSprite.x = dx; [COLOR=Red]// passing 254.01 to someSprite.x, but it was not working!![/COLOR]
trace("x: "+someSprite.x+",dx: "+dx+",vx: "+someSprite.vx*10000);
Output:
x: 254,dx: 2540000,vx: 100
x: 254,dx: 254.01,vx: 100
x: 254,dx: 254.01,vx: 100