This content has been marked as final. Show 3 replies
your first two attempts to post the message omitted that "doesn't work" part.
The reason it doesn't work is because sprite's 'loc' values are always integers. If you set them to a floating point number they'll be rounded to the nearest integer. Because you're subtracting 0.53, it gets rounded down to the nearest integer with the result that it moves one pixel each frame. If you subtracted less than 0.5 (eg, 0.34), you would find that the sprite didn't move at all.
Another comment though,
The fact that you're trying to use very small values to move the sprite implies to me that you're trying to slow down the animation because it's moving too fast - am I correct?
You should really consider going about this animation in a different way, by making the sprite move a small amount each frame update rather than each iteration of a repeat loop with a forced update.
Attached below is a 'behaviour script', which can be attached to your sprite. Create a new behaviour, paste in that script, then drag the behaviour cast member on to your sprite.
You don't need to specify 'sprite(5)' explicitly, because the behaviour can tell which sprite it has been placed on. The sprite will now move the number of pixels specified in the code per frame, at your movie's tempo.
Also, because we're now manipulating a property 'h' (rather than the sprite's locH directly), you can use floating point values to make the animation move slower than one pixel per frame and it will work as expected.
here's a few more examples of simple sprite motion behaviours which might make things clearer too:
hope this helps!
Ben, thanks a lot for your explanation..
Here's what I'm trying to do:
I have a photograph (a panorama) on the stage, which is controlled by two arrows, one to move the photo to the left and one to move it to the right.
Between those arrows, there's also a pointer, which moves also to the left, when the photo does.
When clicked the arrow, the locH of the photograph is moved with 1. Of course, the pointer is much smaller, and should move to the left with much less than 1..