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

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.

主站蜘蛛池模板: 广昌县| 秀山| 健康| 黔西| 通山县| 邓州市| 沁源县| 永平县| 韶山市| 申扎县| 台前县| 宿松县| 邛崃市| 安吉县| 全椒县| 陈巴尔虎旗| 罗平县| 石门县| 上思县| 昌宁县| 区。| 仪陇县| 始兴县| 彩票| 锡林郭勒盟| 准格尔旗| 金溪县| 漳平市| 鄂州市| 安岳县| 平利县| 勃利县| 高邮市| 庆云县| 韩城市| 陵水| 宜川县| 道孚县| 广灵县| 泾川县| 浙江省|