Access to sprite position property


#1

Right now I can only control the scale of a sprite. I want to set the position of a sprite, both directly and with animation.

Example:

go.animate("#sprite_pusher", "position.y", go.PLAYBACK_ONCE_PINGPONG, 20, go.EASING_INQUAD, 1)

#2

The way to currently go is to put the sprite component in a game object. That gives you the full range of runtime movement, rotation and scale possibilities.


#3

Hello @sicher

I don’t know how engine works internally , so i don’t know why scale property is accessible and in the other hand position is not. Also there is a position property for sprites on editor’s property panel, i can set manually sprite position within gameObject’s space.

But good thing is; it works how you offer to handle this situation.


*Pros : Dont know yet. Maybe learn benefits in future.

  • Cons : You have lots of gameObject around.

Best Regards,


#4

As long as the game objects don’t have scripts associated with them, the extra runtime cost is not high.


#5

What if I have several sprites, do I need a game object for each sprite? I want to animate each sprite separately.


#6

Yes, that would require one game object per sprite then. This is perfectly fine and how the engine is designed and supposed to work.


#7

Yup, I’m doing that, is there a way to group game objects?


#8

Yes, you can child a game object to a parent game object. You can do it in the editor while in a collection by drag and dropping a game object on another in the Outline. At runtime you do it via the set_parent message


#9

Why is it not possible to allow setting position of a component with go.set_position()? It’s individual position can be set in the editor, but not in the code, why?


#10

I’ll let @Johan_Beck-Noren or @sven answer this one.


#11

Looking forward to seeing their reply.