Set image origin interacts weirdly with set X?

daverave1212

  • Posts: 44
Hello!
I made an image, then an image instance called 'img' and I set its origin to:

Code: [Select]
setOriginForImage(img, img.width/Engine.SCALE/2, img.height/Engine.SCALE/2);
I did this so I can rotate the image around its exact center with
Code: [Select]
img.rotation = img.rotation + 1;
Now, whenever i want to change the X coordinate of img, it behaves very strangely.
I put this code in an 'Every 0.02 seconds' loop:

Code: [Select]
setXForImage(img, img.x/Engine.SCALE + 1);
trace(img.x/Engine.SCALE);

This drastically changes the X coordinate of img, not even close to 1.
It's X increases very fast, by  around the original width of the image / 2 + 1.
The rotation around the center works fine.

Am I doing something wrong?
Is this a bug?

Thank you!




JeffreyDriver

  • Posts: 2262
Is your 'Every 0.02 seconds' loop in an always/updating event? If so, that loop is being triggered 100 times per second.

daverave1212

  • Posts: 44
Is your 'Every 0.02 seconds' loop in an always/updating event? If so, that loop is being triggered 100 times per second.

The loop is not inside an update/draw/another loop.
Either way, I trace the position of the image at every step, each time after I call 'setXForImage'.
Instead of increasing by 1, it increases by half of its width.