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

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.

主站蜘蛛池模板: 洛扎县| 凌源市| 延长县| 龙海市| 九台市| 哈密市| 沂水县| 巩留县| 房产| 乳山市| 申扎县| 永安市| 肃宁县| 西昌市| 屏东市| 察哈| 黑山县| 屏南县| 闽清县| 无为县| 鄂温| 张家口市| 浦江县| 虞城县| 和龙市| 芦溪县| 思南县| 怀安县| 县级市| 名山县| 龙游县| 额敏县| 分宜县| 和静县| 汨罗市| 长阳| 睢宁县| 黄石市| 定日县| 武鸣县| 三门峡市|