Android的 - 一块拼图 [英] Android - Puzzle Piece

查看:189
本文介绍了Android的 - 一块拼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建为Android拼图应用程序。我是相当遥远的编码和我有点坚持一个问题。

I'm trying to create a jigsaw puzzle app for Android. I am fairly far into the coding, and I am kind of stuck with one issue.

我需要一种方法来改变一个位图成一束的拼图。我现在的code简单地切割图像分为矩形,和它的作品pretty很好,但现在我需要一种方法来创建更复杂的一块形状。

I need a way to change a Bitmap into a bunch of puzzle pieces. My current code simply cuts the image into rectangles, and it works pretty well, but now I need a way to create more complex piece shapes.

我有一对夫妇的想法:


  • 使用仅包含黑色和白色像素独立的位图文件,并用它来切了图片。我认为这是一个pretty很好的计划,直到我去code吧。我真的不知道该怎么做。

  • 使用一个路径对象创建边界。这可能会工作,但我不知道如何保持双方的轨道,这样的作品相互连接。

  • Use a separate bitmap file that contains only black and white pixels, and use that to cut up the picture. I thought this was a pretty good plan, until I went to code it. I really had no idea how to do it.
  • Use a Path object to create the border. This would probably work, except I'm not sure how to keep track of the sides so that the pieces connect with each other.

任何想法?我接受任何建议。

Any ideas? I'm open to any suggestions.

推荐答案

您可以使用路径和/或地区设置剪辑为你的画布绘制时,位图

You can use Path and/or Region to set a clip for your Canvas when drawing a Bitmap.

看看<一个href=\"http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Clipping.html\"相对=nofollow>这个例子的。以下是裁剪绘图任何形状的一些方法。

Take a look at this example. Here are some ways of clipping your drawing to any shape.

这篇关于Android的 - 一块拼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆