What is the purpose of setTouchAreaBindingOnActionDownEnabled - AndEngine?

蓝咒 提交于 2019-12-25 04:38:04

问题


I am starting to work with AndEngine and I see that some tutorials use setTouchAreaBindingOnActionDownEnabled but don't explain its purpose.

Why I need to use this method together with onAreaTouched? Should not be onAreaTouched enough and detect inside of it whether is DOWN or UP?

Thanks


回答1:


The purpose of the method setTouchAreaBindingOnActionDownEnabled is to be able to "Bind" the sprite/button/etc to a scene/hud.

For example, if you only use the onAreaTouched for a controller in a race game. When you click on gaz (action down) it accelerates and when you remove your finger ( action up ) decelerates. But what happens if you click and keep your finger and swipe ( move ) outside the button area? In this case the button action up is not called and although your finger is no longer on the button the car still keeps accelerating.

Thus instead of managing this scenario manually, the setTouchAreaBindingOnActionDownEnabled will handle this type of scenario for you

Source: AE developer



来源:https://stackoverflow.com/questions/19754670/what-is-the-purpose-of-settouchareabindingonactiondownenabled-andengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!