[英]How to split image into small parts and display them on click with React Native?
This is what I'm aiming to achieve I'm making a small quiz game in React Native where you guess the image by clicking on different parts of it.这就是我想要实现的目标。我在 React Native 中制作了一个小测验游戏,您可以通过单击图像的不同部分来猜测图像。 Initially the image is behind multiple small "blocks" and by clicking on them they disappear.最初,图像位于多个小“块”后面,点击它们就会消失。 How can achieve this functionality in the most elegant way?如何以最优雅的方式实现此功能? I was thinking of making multiple small Views each with the same size and onclick they would disappear.我正在考虑制作多个大小相同的小视图,并且 onclick 它们会消失。 Is this a good approach?这是一个好方法吗? Here's the image of what I'm aiming to achieve: Guess image app这是我想要实现的图像: Guess image app
In my opinion, your approach is the only one.在我看来,你的方法是唯一的。 If you try to split your image, there will be somethings you have to deal with:如果您尝试拆分图像,您将需要处理一些事情:
And these are some props when you use blocks
:这些是您使用blocks
时的一些道具:
blocks
, eg: increasing the difficult by adding more blocks, creating block's animation like rolling or phasing, etc.你可以用这些blocks
做很多事情,例如:通过添加更多积木来增加难度,创建积木的 animation 像滚动或相位等。<Image/>
component, RN has built in <ImageBackground/>
component to meet up your requirements.如果您不想将绝对 position 设置为您的<Image/>
组件,RN 已经内置了<ImageBackground/>
组件来满足您的要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.