官术网_书友最值得收藏!

Coin animation

When you created the Coin scene, you added an AnimatedSprite, but it isn't playing yet. The coin animation displays a shimmer effect traveling across the face of the coin. If all the coins display this at the same time, it will look too regular, so each coin needs a small random delay in its animation.

First, click on the AnimatedSprite and then on the Frames resource. Make sure Loop is set to Off and that Speed is set to 12.

Add a Timer node to the Coin scene, and add this code to _ready():

$Timer.wait_time = rand_range(3, 8)
$Timer.start()

Now, connect the timeout() signal from the Timer and add this:

func _on_Timer_timeout():
$AnimatedSprite.frame = 0
$AnimatedSprite.play()

Try running the game and watching for the coins to animate. It's a nice visual effect for a very small amount of effort. You'll notice a lot of effects like this in professional games. Though very subtle, the visual appeal makes for a much more pleasing experience.

The preceding Powerup object has a similar animation that you can add in the same manner.

主站蜘蛛池模板: 桐城市| 寻甸| 武胜县| 邳州市| 印江| 临泉县| 景宁| 广饶县| 阿勒泰市| 牡丹江市| 开封市| 易门县| 铅山县| 原阳县| 合水县| 和硕县| 海晏县| 沙田区| 长岭县| 民县| 晋江市| 惠来县| 溆浦县| 兴化市| 永修县| 黑山县| 云林县| 略阳县| 广饶县| 依安县| 深水埗区| 合山市| 临漳县| 镇赉县| 易门县| 龙江县| 天峨县| 平乡县| 德保县| 禄丰县| 原平市|