0

我正在用 cocos2dx 开发一个游戏,我有一个迷宫的精灵,采用 png 格式(墙壁和其他区域是透明的)。

我想知道是否有任何方法可以检测到精灵中与这些墙壁的碰撞。玩家将通过触摸拖动对象并解决迷宫。

欢迎任何想法。

4

1 回答 1

0

basically what you need is map object's coordinates to image coordinates and then read pixel data at this image

for example, you have you sprite 8x8 pixels, but draw 256x256 world, ie each pixel in sprite is 32x32 texture

you have ball coordinates in "word", lets say 100x100, so just divide them by 8 = 12x12 - check this pixel in sprite

also, check out this tutorial for ios, it can give you additional ideas

于 2013-10-18T18:23:53.653 回答