Use tile_0151.png. as the texture.
Add a script to the Coin node
Note that we can only set the coins starting y position once the node is ready
bob_height determines how many pixels the coin will move up and down by.
bob_speed is how fast the coin moves up and down
start_y records the y position the coin needs to move back to when bobbing
t is a time value and will increase with every frame
We will move our coin up and down using a sin wave
This is just a repeating pattern over time.
We will increase t and then pass that to a built in sin wave function
We will get a value between 0 and 1
We will save this in a variable called d (sin delta / change in sin over time)
This formula moves along a sin wave at a rate of t * bob_speed
Then we add 1 and divide by 2
To change the output from -1 and 1 to
Now we can add a line to move the coin up and down between 0 and 1
To collect the coin we must
add the body_entered signal and connect it.
Then code the signal in the coin script to
increase the score and destroy the coin.
Now you can add coins to the level for the player to collect.