任何人都可以帮我修复 getPointerCount()
、getX()
和 getY()
上的此错误吗?
Multiple markers at this line
The method
getPointerCount()
is undefined for the typeMotionEvent
代码
int pointerIndex;
public boolean onTouchEvent(MotionEvent event)
{
float xPosition1 = 0;
float yPosition1 = 0;
float xPosition2 = 0;
float yPosition2 = 0;
for (pointerIndex = 0; pointerIndex < event.getPointerCount(); pointerIndex++) //Error
{
if (pointerIndex == 0)
{
xPosition1 = event.getX(pointerIndex);// Error
yPosition1 = event.getY(pointerIndex);//Error
}
if (pointerIndex == 1)
{
xPosition2 = event.getX(pointerIndex);//Error
yPosition2 = event.getX(pointerIndex);//Error
}
}
最佳答案
getPointerCount()
从 API 级别 5 开始可用。如果您使用任何早于 Android 2.0 的 SDK,您将收到该错误。
关于android - Android 游戏中 onTouchEvent 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6317157/