gpt4 book ai didi

java - LibGDX 飞翔的小鸟克隆,Scene2d actor(按钮)

转载 作者:行者123 更新时间:2023-12-02 05:33:10 25 4
gpt4 key购买 nike

所以,我正在开发一个 flappybird 克隆。我创建了一个弹跳小鸟的按钮。我还想要这个按钮是绘制一些东西(此时完全不相关)。但并非每次按下按钮时都会如此。我已经尝试过:

if (Gdx.input.isTouched()) {
batcher.draw(birdRed, bird.getX(), bird.getY(),
bird.getWidth() / 2.0f, bird.getHeight() / 2.0f,
bird.getWidth(), bird.getHeight(), 1, 1, 1);
}

但这就是我现在想要的。我想专门在第一次按下按钮时绘制一些东西。我希望你理解我的问题。感谢您的帮助。

最佳答案

boolean touched = false;

...

if (Gdx.input.isTouched() && !touched) {
touched = true;
batcher.draw(birdRed, bird.getX(), bird.getY(),
bird.getWidth() / 2.0f, bird.getHeight() / 2.0f,
bird.getWidth(), bird.getHeight(), 1, 1, 1);
}

关于java - LibGDX 飞翔的小鸟克隆,Scene2d actor(按钮),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25312318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com