在android中移动带有重复位图图像的路径
我目前正在编写一个 Android 横向卷轴游戏,但在使用重复位图图像填充路径时遇到问题。我正在从多个坐标创建一条路径来组成“地面”区域。我有一个角色固定在画布和屏幕的中间,并移动路径来代表角色的运动。我已经能够使用 BitmapShader 用重复图像填充路径。我还可以在屏幕上将路径形状从一侧移动到另一侧。但是,位图着色器似乎使用默认原点 0,0,这意味着着色器始终在同一位置绘制地面重复图像。这意味着即使路径在移动,地面重复的图像也永远不会移动。有谁知道如何更改着色器的原点或知道用重复图像填充路径的更好方法?
或者,有人可以建议一个更好的解决方案来用图像填充可绘制形状吗?
谢谢 安迪
I'm currently writing an android side-scrolling game and am having trouble filling a path with a repeating bitmap image. I'm creating a path from a number of coordinates to make up the "ground" area. I have a character who is fixed in the middle of the canvas and screen and am moving the path to represent the movement of the character. I've been able to fill the path with a repeating image using a BitmapShader. Also I can move the path shape from side to side on the screen. However, the Bitmapshader seems to be using a default origin of 0,0 which means the shader is always drawing the ground repeating image in the same place. This means that even though the path is moving the ground repeated image never appears to move. Does anyone have any idea how to change the origin of the shader or know of a better way to fill the path with a repeating image?
Alternatively, can anyone suggest a better solution for filling a drawable shape with an image?
Thanks
Andy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谢谢,看看那些...Replica Island 似乎经常使用 OpenGL,目前这有点超出了我的能力,而 Snake 并没有完全做到我想要的...最终到达了那里..
Thanks, had a look at those...Replica Island seems to use OpenGL quite a lot which is a bit beyond me at present and Snake didn't quite do what I was looking for...eventually got there..
您看过 android sdk 中的 Snake 示例吗?另外,Replica Island 是如何在 Android 中创建图块引擎的另一个示例。
Have you looked at the Snake example in the android sdk? Also Replica Island is another example of how to do a tile engine in android.