LIBGDX无限RepeatAction中断

时间:2018-04-14 21:25:01

标签: java libgdx

我需要编写一个构建最高的堆栈游戏,有一个块移动站点到站点,在键入SPACE之后它应该下载到已经构建的堆栈上。

SequenceAction overallSequence = new SequenceAction();
    overallSequence.addAction(Actions.moveTo(0, block.getY(), 0.5f));
    overallSequence.addAction(Actions.moveTo(800 - block.getWidth(),
            block.getY(), 0.5f));
    RepeatAction infiniteLoop = new RepeatAction();
    infiniteLoop.setCount(RepeatAction.FOREVER);
    infiniteLoop.setAction(overallSequence);

我遇到问题,SPACE事件需要打破该循环并开始新操作,在堆栈上删除块。

我尝试使用Action.sequence,操作集清除和重置,但没有相当大的结果。

2 个答案:

答案 0 :(得分:1)

我尝试过你的方式,但有一些线程问题

[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has 
not been called 
[xcb] Aborting, sorry about that.
java: xcb_io.c:165: dequeue_pending_request: Assertion
`!xcb_xlib_unknown_req_in_deq' failed.

答案 1 :(得分:0)

要将移动站点分解为站点循环,只需清除块Actor block = ...; block.addAction( Actions.forever( Actions.sequence( Actions.moveTo(...), Actions.moveTo(...) ) ) ); 的操作即可。总的来说,你可以做到这一点:

1)无限移动space

block.clearActions();
// drop the block
block.addAction(Actions.moveBy(...)); // or block.addAction(Actions.moveTo(...));

2)按下SELECT test_id FROM test GROUP BY test_id HAVING MAX(result) = MIN(result) 键时:

{{1}}