Page 1 of 1
How to spawn tokens at a specific x or y
Posted: 09 February 2025, 08:25
by gamemaker0
I am trying to make a game of connect 4 and would like to have the tokens slide down the board as they would in real life, but for right now they just spawn at a random spot at the top of the board and moves to their designated location. I am using the Reversi tutorial code as the base if that helps.
Re: How to spawn tokens at a specific x or y
Posted: 09 February 2025, 11:50
by RicardoRix
Re: How to spawn tokens at a specific x or y
Posted: 09 February 2025, 17:57
by KuWizard
RicardoRix wrote: ↑09 February 2025, 11:50
slideToObjectPosition() might be what you need.
As far as I can see, slideToObjectPos() just uses x and y to offset the sliding object from the target object location.
I would suggest to create a fake invisible element whenever it is needed to start the animation and slide the object from it to a needed position
Re: How to spawn tokens at a specific x or y
Posted: 09 February 2025, 21:46
by RicardoRix
KuWizard wrote: ↑09 February 2025, 17:57
RicardoRix wrote: ↑09 February 2025, 11:50
slideToObjectPosition() might be what you need.
As far as I can see, slideToObjectPos() just uses x and y to offset the sliding object from the target object location.
I would suggest to create a fake invisible element whenever it is needed to start the animation and slide the object from it to a needed position
fastidious much..
He doesn't actually provide the exact code. I linked the document with all the details.
Re: How to spawn tokens at a specific x or y
Posted: 13 February 2025, 06:27
by gamemaker0
Alright, so with the help of my classmates I was able to use one of the per-existing divs used to make the board and simply have the token spawn at the same x as the final destination with the y being set to 1. Thank you both for the advice as it did help with understanding how the function worked,and thank you RicardoRix for providing me the link to the animations document, I intend on learning more about animations to make the game look better.