Hello everyone !
I'm trying to automate a particular behaviour of buttons being created at runtime.
When the player clicks on a sprite ("Sprite1"), a serie of new smaller sprites ("Sprite2") should appear all around Sprite1.
Every Sprite2 is visually linked to Sprite1 with a solid white line.
In the end, the Sprite 2 should look like the rays of a sun, evenly distributed all around Sprite1, regardless of their number (for example, if 4 Sprite2 are created, they would each go in a different direction at 90°, but if there are 6 Sprite2, they would each be at 360/6° all around Sprite1, etc.)
Then, once every SPrite 2 has appeared, they will each spawn another sprite ("Sprite3") on their center - but each one of those Sprite3 is different (but has to be distributed in the right order) - I have a hunch using families will be useful for that one...
Here is the code I wrote for the spawn animation of Sprite 2 (composed of a line and a square) ; the sprite named "subbut_mouth01" corresponds to a Sprite3) ; to summerize : when the player clicks on a button, a white line is created on the originPoint of the button ; that line is created at 0 height, and goes to a 150px height with a lerp ; once that height is achieved, a white square is also created on the top origin point of the white line, and then, once the square is at the right dimensions, the Sprite3 appears in the square)
And here is a quick sketch of what I'm trying to achieve :
What I'm having difficulties with is :
- automate the creation of Sprite2 with only a simple parameter (the number of instances to create) to adjust, with that parameter being also linked to the angle at which every new sprite2 should be created
- specify in the code which sprite3 should go with which sprite2 (I'd like that to be "automatic", as long as there are the same number of sprite2 that appear as there are sprite3 needed to display.
Thanks in advance for tour help and tips !