ImageSprite's Y pos resets back to 0 whenever a speed value is added

Hey, so I have a image sprite that starts above the canvas at y -300, but whenever i change the speed value on that sprite, it always resets back down to y 0. How can I stop this from happening?

It doesn't. You cannot set an imageSprite outside of the canvas dimensions.

To work around this, you can put a canvas inside an arrangement (centre/centre) and make the canvas dimensions bigger than the arrangement. Then you can put an imageSprite out of sight.

1 Like

It works for the bottom part of the canvas but how would I do it for the top part?

I get the same behaviour if sprite above (Y=0) or below(Y=canvas.height).

It appears that you can set their initial position off canvas but as soon as heading/speed come into play, they are brought back into the canvas. See my workaround above

1 Like

I hear your workaround but I wouldn't know how to set it up, when I tried it, it doesn't seem to work correctly for me.

this did not work, it only set it to the bottom edge instead of also going to the top.

Try this out

spriteOut.aia (3.0 KB)

i tried it out and it still didnt work for what I am doing

This is not very helpful if you want to find a solution!

Did my example work ? (placement of imagesprites out of view, then move into view when speed changed?)
In your project, what doesn't work?
Show your design parameters and layout, relevant blocks, (or share your aia project) explain how you want it to work?

  1. yes your example worked, I tested it and the imagesprites moved into and out of view.
  2. the asteroids spawn at the top of the canvas when I need them to spawn just above the sight line
    3.AsteroidDestroyer.aia (371.0 KB)

You have not set your canvas inside a vertical arrangement? Do this, and make sure your canvas is bigger than the vertical arrangement for your asteroids to spawn out of sight. It is easier to use actual dimensions in pixels, but if you want to use screen width / height, you can, you may need a clock timer to help you set the size of the canvas in relation to the size of the vertical arrangement, it sometimes needs a little time (e.g. 250ms) to catch up with itself.

You can set your fighter further up the canvas so that it is in view.


spriteOutv2.aia (7.8 KB)

1 Like