【发布时间】:2016-11-09 19:23:35
【问题描述】:
如何使用代码使精灵用鼠标拖动?我正在写战舰游戏的代码,我需要鼠标拖动的代码。
【问题讨论】:
-
到目前为止你尝试过什么?你知道怎么画精灵吗?你知道如何捕捉鼠标输入吗?您在哪个部分遇到了问题?
-
是的,我知道怎么画,但我在拖动时遇到了问题
标签: sfml
如何使用代码使精灵用鼠标拖动?我正在写战舰游戏的代码,我需要鼠标拖动的代码。
【问题讨论】:
标签: sfml
首先考虑拖动时应该发生什么,
既然我们已经列出了,我们现在可以考虑第二步,将其转换为伪代码。
if ( check here if the user is moving )
{
if ( check here if the user is holding left button )
{
if ( check here if mouse is inside the sprite )
{
set the position to the mouse pointer.
}
}
}
你明白了吗? :)
【讨论】: