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)
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)
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.
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.
Best Regards,
As long as the game objects don’t have scripts associated with them, the extra runtime cost is not high.
What if I have several sprites, do I need a game object for each sprite? I want to animate each sprite separately.
Yes, that would require one game object per sprite then. This is perfectly fine and how the engine is designed and supposed to work.
Yup, I’m doing that, is there a way to group game objects?
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
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?
Looking forward to seeing their reply.
So, I can change “scale” of the #sprite component from code by go.set("#sprite", "scale", scale)
but can’t change scale in Editor.
But I can change #sprite position in editor, but there is no way to change position from code?
That looks weird. I want to change my sprite’s position from code (and scale in Editor will be also nice)
We will look into exposing the sprite scale from within the editor.
You are not able to change the position of any component at runtime. This is likely not going to change anytime soon.
Change the position of the game object. Or put the sprite in a child game object and move that object instead.