Set Origin for Image API Question [SOLVED]

supremelorax

  • Posts: 41
Greetings.
I have been experimenting with various strategies but am really running into a wall with the behavior of the image API for my situation.

I have an actor, whose angle gets changed, and what needs to happen, is an image of the same size is overlaid, then adjusted to match the angle and position. The actor then slides off in the angle it is pointing creating the illusion of growth.

The issue is that for the actor, I have set the origin at the bottom center, which means it rotates from there. That works exactly as it should. When I overlay the image, and try to set origin for x+width/2 and y+height (to set the same point of rotation), then ask it to match direction, it ends up at some coordinates quite a distance away from where it needs to be. Maybe there is something I am missing in setting the point of origin?
Any help with this would be greatly appreciated as I would rather use image API for this feature than actors.

« Last Edit: March 09, 2021, 07:03:29 pm by supremelorax »

Luyren

  • *
  • Posts: 2782
You need to use the "set origin" block on your image instance to change its origin point. This will enable it to rotate and grow using your desired origin point. Assuming you are already using that, you need to set the origin point within the image. Adding the X and Y coordinates of your actor will obviously go way beyond the image bounds. Remove only the X and Y of your set origin operation and you should be good to go.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

supremelorax

  • Posts: 41
Hey Luyren! Thank you and nice to see you still active here!
I see what you are saying. I think I am trying to make it over complicated by making use of the x and y coordinates.

Can I set the point of origin before attaching an image instance, or does it need to already be attached to calculate that point? I am guessing the origin block is able to calculate and compensate for scale and position within the scene.

At the moment I succeeded in my original goal by setting the point of origin to x=width/2 and y+height of the image instance as you said and things seem to be lining up now.

Luyren

  • *
  • Posts: 2782
Can I set the point of origin before attaching an image instance, or does it need to already be attached to calculate that point? I am guessing the origin block is able to calculate and compensate for scale and position within the scene.
That block is specific for image instances, so you need at least an image instance attribute holding the instance to target with that block. Attaching can be done afterwards, I reckon.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.