如何添加一个精灵总是在屏幕上的Cocos2d? [英] How to add a sprite that is always on the screen in Cocos2d?

查看:215
本文介绍了如何添加一个精灵总是在屏幕上的Cocos2d?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c ++中使用cocos2d-x v3做一个平台游戏,其中地图通常非常大,可见屏幕通过地图跟踪对象。

I'm doing a platformer game using cocos2d-x v3 in c++, where the maps are usually very large, the visible screen follows the object through the map.

假设我想在屏幕的右上角显示一个精灵,即使当屏幕跟随对象时,它也会在这个位置。

Let's say I want to show a sprite in the top right corner of the screen and it would be in this position even when the screen is following the object.

使用对象位置不会这样做。

Using the object position doesn't do it.

有没有办法在屏幕上显示精灵或任何东西,即使屏幕移动,它也会在屏幕上?

Is there a way to show a sprite or whatever in the screen and it would be in the screen even when the screen is moving?

Ps。我是游戏开发中的超级noob

Ps. I'm super noob in game development

推荐答案

我已经设法使用视差节点,子画面转到Vec2(0,0),这样它总是保持在屏幕上的同一位置。

I've managed to do it using a Parallax Node, and using the velocity which the sprite goes to Vec2(0,0), this way it stays always on the same spot in the screen.

这篇关于如何添加一个精灵总是在屏幕上的Cocos2d?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆