平稳运动
Smoothly movement
我想在单击按钮时移动:向左。
这是移动移动...
问题出在它的移动上,但只有一次。我需要垃圾邮件点击按钮...
代码:
创建中:
this.buttonleft.inputEnabled = true;
this.buttonleft.events.onInputDown.add(this.clickMoveLeft, this);
this.buttonleft.mouseDownCallback = false;
this.buttonleft.alpha = false; // Making no visable
在所有内容下 - 单独的功能:
clickMoveLeft: function()
{
if(!this.clickMoveLeft.mouseDownCallback)
{
this.player.body.velocity.x = -160;
this.buttonleft.mouseDownCallback = true;
}
else if (!this.clickMoveLeft.mouseUpCallback)
{
this.player.body.velocity.x = 0;
this.buttonleft.mouseDownCallback = false;
}
我不知道移相器框架,但是,知道 js 事件是如何工作的,并且在 quick search in the docs 之后,我很确定 .mouseDownCallback 回调只会在您单击鼠标时触发一次,并且不会继续。
所以你可以使用 mousedown 事件来调用一个函数来继续移动你想要移动的东西,然后使用 mouseup 来停止它。
我想在单击按钮时移动:向左。 这是移动移动...
问题出在它的移动上,但只有一次。我需要垃圾邮件点击按钮...
代码:
创建中:
this.buttonleft.inputEnabled = true;
this.buttonleft.events.onInputDown.add(this.clickMoveLeft, this);
this.buttonleft.mouseDownCallback = false;
this.buttonleft.alpha = false; // Making no visable
在所有内容下 - 单独的功能:
clickMoveLeft: function()
{
if(!this.clickMoveLeft.mouseDownCallback)
{
this.player.body.velocity.x = -160;
this.buttonleft.mouseDownCallback = true;
}
else if (!this.clickMoveLeft.mouseUpCallback)
{
this.player.body.velocity.x = 0;
this.buttonleft.mouseDownCallback = false;
}
我不知道移相器框架,但是,知道 js 事件是如何工作的,并且在 quick search in the docs 之后,我很确定 .mouseDownCallback 回调只会在您单击鼠标时触发一次,并且不会继续。 所以你可以使用 mousedown 事件来调用一个函数来继续移动你想要移动的东西,然后使用 mouseup 来停止它。