如何从 AtlasSpriteManager 创建纹理?
我想要做的是使用 1024x1024 图像创建一个巨大的纹理(宽度超过 1024)。我可以使用 AtlasSpriteManager 检索图像,但每当我尝试从管理器检索纹理时,我只能获取第一张图像。
我需要在管理器中设置每个 AtlasSprite 的位置以制作较长的纹理。
有什么建议吗?
What I want to do is create a huge texture(w/ width of more than 1024) using a 1024x1024 image. I can retrieve the images using an AtlasSpriteManager, but whenever I try to retrieve the texture from the manager I can only get the first image.
I need to set the position of every AtlasSprite in the manager to make a lengthy texture.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来你想创建一个平铺纹理。非常肯定 Cocos 有一个特定的 API,但我会检查他们的 文档并在那边的论坛上询问以确定。
更新:我确实为我正在开发的一款游戏创建了一个解决此问题的可行解决方案,该解决方案是创建一个包含所有要用作较大背景的纹理的数组。将它们放置在添加到 Cocos2D 中时并排放置的位置。通过这种初始放置,图像看起来就像是一个大背景。这效果非常好,当 Apple 批准它时,您可以在 iPad 版 Addicus 游戏中看到结果,希望很快就会批准它。 Addicus 使用六个 1024x768 纹理作为背景。使用此解决方案时需要记住两件事...
当您移动任何平铺图像时(毫无疑问您会这样做),您将需要将所有平铺图像移动相同的量和相同的方向。这可以防止图块破裂并破坏大背景的幻觉
当您移动背景块时,您可能会注意到瓷砖块之间存在间隙。要消除这种情况,请使图块重叠 1 个像素。
Sounds like you want to create a tiled texture. Quite sure Cocos has a specific API for that but I would check their documentation and ask on the forum over there to be sure.
UPDATE: I did create a working solution for this issue for a game I am working on which was to create an array of all the textures you want to use as the larger background. Position them so they are side by side when added into Cocos2D. With this initial placement the images will look like they are one big background. This works wonderfully and you can see the result in the game Addicus for iPad when Apple approves it which should hopefully be soon. Addicus is using six 1024x768 textures for the background. Two things to keep in mind with this solution...
When you move any of the the tiled images (which you no doubt will be) you will need to move all the tiles by the same amount and in the same direction. This prevents the tiles from breaking apart and ruining the illusion of a large background
You will likely notice a gap between tile pieces as you move the background pieces. To eliminate this make the tiles overlap by 1 pixel.