这个控制结构的执行流程是怎样的
protected void onDraw(Canvas canvas)
{
if (x == getWidth() - bmp.getWidth())
{
xSpeed = -1;
}
if (x == 0)
{
xSpeed = 1;
}
x = x + xSpeed;
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(bmp, x , 10, null);
}
假设 x = 0
和 xSpeed = 1
,它是如何工作的
请向我解释一下。
protected void onDraw(Canvas canvas)
{
if (x == getWidth() - bmp.getWidth())
{
xSpeed = -1;
}
if (x == 0)
{
xSpeed = 1;
}
x = x + xSpeed;
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(bmp, x , 10, null);
}
Let's say x = 0
and xSpeed = 1
,how does it work
Please explain this to me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行流程始终是从上到下。因此您可以看到代码将如何执行。
flow of excution is always top to buttom.So you can see your code how it will execute.