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

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.

主站蜘蛛池模板: 曲麻莱县| 包头市| 全州县| 磐安县| 朝阳县| 霍城县| 三亚市| 南平市| 阿拉善盟| 原平市| 南华县| 郑州市| 昌吉市| 漾濞| 天台县| 靖江市| 青岛市| 六枝特区| 宁国市| 宁城县| 武川县| 泉州市| 宁化县| 屏南县| 潜山县| 府谷县| 唐山市| 翁牛特旗| 都兰县| 四会市| 黔江区| 万盛区| 正阳县| 漳浦县| 华池县| 肥乡县| 石棉县| 汉川市| 夹江县| 广昌县| 三原县|