android:在动画期间监视移动点按钮的x、y坐标
在我的应用程序中,有8个点从顶部下降到底部,我想知道如何添加代码,以便每个点都可以更新其x、y坐标,以便在适当放置下方的篮子时,它将记录分数+1 代码: 宣言 以这种方式设置点的动画: 问题: 如何监控每个点的x,y坐标,例如,x位于篮框宽度内,y位于篮框顶部,点被视为进入篮框的索android:在动画期间监视移动点按钮的x、y坐标,android,animation,coordinates,Android,Animation,Coordinates,在我的应用程序中,有8个点从顶部下降到底部,我想知道如何添加代码,以便每个点都可以更新其x、y坐标,以便在适当放置下方的篮子时,它将记录分数+1 代码: 宣言 以这种方式设置点的动画: 问题: 如何监控每个点的x,y坐标,例如,x位于篮框宽度内,y位于篮框顶部,点被视为进入篮框的索 谢谢 对于上述问题,我还没有找到直接的解决办法。 相反,我添加了一个时间计数器,当毫秒到达时,例如,%3000=0,它将调用检查条件来检查视图上的所有点。这样,它的工作原理就好像一直在检查一样 // colle
谢谢 对于上述问题,我还没有找到直接的解决办法。 相反,我添加了一个时间计数器,当毫秒到达时,例如,%3000=0,它将调用检查条件来检查视图上的所有点。这样,它的工作原理就好像一直在检查一样
// collections of spots (Buttons) and Animators
private final Queue<Button> spots = new ConcurrentLinkedQueue<Button>();
// adds a new spot at a random location and starts its animation
public void addNewSpot()
{
int x = random.nextInt(viewWidth - SPOT_DIAMETER);
int y = 0 - SPOT_DIAMETER;
int x2 = x;
int y2 = (viewHeight);
// create new spot
final Button spot = (Button) layoutInflater.inflate(R.layout.untouched, null);
spots.add(spot);
spot.animate().x(x2).y(y2).scaleX(SCALE_X).scaleY(SCALE_Y).setDuration(animationTime).setListener
(
new AnimatorListenerAdapter()
{
@Override
public void onAnimationStart(Animator animation)
{
animators.add(animation); // save for possible cancel
}
public void onAnimationEnd(Animator animation)
{
animators.remove(animation); // animation done, remove
if (!gamePaused && spots.contains(spot)) // not touched
{
XX = (int) spot.getX();
YY = (int) spot.getY();
missedSpot(spot); // lose a life
}
}
}
);