这是我的cocos代码:
class Startbox(Layer):
def __init__(self):
Layer.__init__(self)
self.batch = BatchNode()
self.add(self.batch)
img = pyglet.image.load('images/map_sprites.png')
tileset = pyglet.image.ImageGrid(img, 3, 15, 96, 96)
x, y = 0, 0
for i in range(10):
for j in range(10):
spr = Sprite(tileset[1])
spr.x = x
spr.y = y
self.batch.add(spr)
x += 96
y += 96
x = 0
我想买一个雪碧,显示器并排放在窗户上。 该代码生成错误结果,图块之间有一个空格,如下所示:
我不明白为什么会发生这种情况,也不知道如何解决它。下面的pyglet代码基本上是相同的,但是精灵正确排列,不会产生任何黑线:
^{pr2}$编辑:我找到了解决方案,为了清楚起见,我想把它作为一个答案发布,以防将来有人偶然发现,但我想编辑我的作品就足够了。在
从列表中的克劳迪奥•卡内帕(Claudio Canepa):
You can try passing do_not_scale=True in the director.init call , this will use ortographic projection which is better suited for tiles.
You can look at examples for cocos tilemaps in the scripts
test_tiles.py
test_tmx.py
test_platformer.py
实现非常简单:
if __name__ == '__main__':
director.init(width, height, do_not_scale=True)
director.run(Scene(Startbox()))
在python版本的cocos2d中不起作用,但在iPhone版本的cocos2d中观察到了相同的情况。所以这可能会有所帮助:
«如果使用Zwoptex创建SpriteSheet,则将sprite间距添加到2px+。在
«编辑ccConfig.h文件并定义
{我的回答:^参考}
相关问题 更多 >
编程相关推荐