滚动背景

发布于 2024-09-14 07:56:48 字数 126 浏览 3 评论 0原文

我正在尝试纵向模式下的简单游戏的新功能,我想为游戏添加无缝滚动背景,图像为512x512px。

我想要的主要滚动是垂直滚动,但我希望也能够在图像大小的范围内横向滚动。我应该如何处理这个问题,我正在使用cocos2d。 大卫

I'm trying out new things for a simple game in Portrait mode, I want to add a seamless scrolling background to a game, the image is 512x512px.

The Main scrolling I want to have is Vertically, but I want to be able to scroll sideways too within the bounds of the image size. How should I go about with this, I'm using cocos2d.
David

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吖咩 2024-09-21 07:56:48

尝试重复纹理(在本例中在 2000 像素内)

CGRect repeatRect = CGRectMake(0, 0, 2000, 2000);
CCSprite *background = [CCSprite spriteWithFile:@"Background.png" rect:repeatRect];
ccTexParams params =
{
    GL_NEAREST,
    GL_NEAREST_MIPMAP_LINEAR,
    GL_REPEAT,
    GL_REPEAT
};
[background.texture setTexParameters:¶ms];

Try repeating the texture (in this case within 2000px)

CGRect repeatRect = CGRectMake(0, 0, 2000, 2000);
CCSprite *background = [CCSprite spriteWithFile:@"Background.png" rect:repeatRect];
ccTexParams params =
{
    GL_NEAREST,
    GL_NEAREST_MIPMAP_LINEAR,
    GL_REPEAT,
    GL_REPEAT
};
[background.texture setTexParameters:¶ms];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文