【问题标题】:How to Move image in SurfaceView from top to bottom only [closed]如何仅从上到下移动 SurfaceView 中的图像[关闭]
【发布时间】:2012-12-16 22:03:15
【问题描述】:

我想知道有人帮助我如何实现 bug Smasher 简单功能, 我想从上到下移动图像,并想在有人点击图像时更改图像,就像 Bug Smasher Game 一样。我知道 SurfaceView n 能够在 SurfaceView 上绘制图像。

代码,示例?

请帮忙。

谢谢

【问题讨论】:

    标签: android image bitmap surfaceview


    【解决方案1】:

    请提供更多信息并编码您如何移动图像。也许我的一个项目的这个小例子会对你有所帮助。

    float x = 0,y = -1;
    public void onDrawFrame(GL10 gl) 
    {
       float delta = 0;
       long currentFrameStart = System.nanoTime();
       if(lastFrame!=0)
          delta = (currentFrameStart-lastFrame) / 1000000000.0f;
       lastFrame = currentFrameStart; 
    
       antTexture.bind();
    
       gl.glPushMatrix();
    
       y += delta*0.1f;
       gl.glTranslatef(x, y, 0 ); 
       //gl.glRotatef(angle, 0, 0, 1);
    
       antMesh.render(PrimitiveType.TriangleFan, 0, 4);
    
       gl.glPopMatrix(); 
    }
    

    我在我的游戏 Orc Genocide 中实现了 Ant Smasher 的迷你游戏版本

    【讨论】:

      猜你喜欢
      • 2012-01-05
      • 1970-01-01
      • 1970-01-01
      • 2013-05-27
      • 2013-02-28
      • 2015-03-06
      • 2012-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多