How to do a fixed sprite (that don't move with my camera) in libgdx?

user3421416

How can i do a fixed sprite that don't move with my camera (for example: a life bar in the left up corner)?

I have already tried to do this in the hard way and i would like to see if there is a simple way to do this.

Is there a simple way to do that or i need to do this in relative to the player position?

And i am sorry for my broken english, I would be very grateful to those who answer me.

thankyou.

noone

Usually for the task of UI you would use an extra scene2d Stage and implement custom subclasses Actor which you add to the Stage and set their fixed position via Actor.setPosition(). There are already several predefined UI elements in the scene2d.ui package. To simulate a healthbar you could either use a ProgressBar, or you implement your own HealthBar extends Actor, which renders a Sprite of your choice.

The stage is stationary by default and has its own Camera. As long as you do not manipulate that camera anyhow, you can just draw the stage with all elements via stage.draw() and it will always remain at the same place (what you would expect from an ingame HUD).

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

libGdx: Sprite is not drawn when there is a stage

来自分类Dev

Libgdx Sprite不能平稳移动

来自分类Dev

Sprite LibGDX中的视差滚动

来自分类Dev

Libgdx Sprite不能平稳移动

来自分类Dev

LibGdx-必须在Sprite中设置Sprite或Texture?

来自分类Dev

libGdx:有舞台时不绘制Sprite

来自分类Dev

LibGDX Flip 2D Sprite动画

来自分类Dev

如何通过Sprite对象处理Libgdx纹理

来自分类Dev

Libgdx Java Sprite大小问题

来自分类Dev

Why don't my points display in Haskell OpenGL?

来自分类Dev

Moved to the 5 GHz band but my old devices don't see it

来自分类Dev

LibGDX Sprite批处理字体缩放比例不好

来自分类Dev

控制和创建多个Sprite数组Java Libgdx

来自分类Dev

Libgdx Sprite深度在Android上与在桌面上不同

来自分类Dev

LibGDX batch.draw vs sprite.draw性能

来自分类Dev

libgdx在运行时更改Image Sprite

来自分类Dev

How do I parse my JSON with external middleware now that Express doesn't carry a body parser?

来自分类Dev

How can we prevent that when I resize my window, my images move using HTML-CSS?

来自分类Dev

libgdx,什么时候使用camera.position.set?

来自分类Dev

How to select all elements that don't have a class or id?

来自分类Dev

How to get perforce to pull only files that don't exist in workspace

来自分类Dev

I don't see .bashrc file in my /home and /etc/skel direcories

来自分类Dev

libgdx 模型实例位置在调用 camera.position.set 或 camera.lookat 后改变

来自分类Dev

How do i sort my listview alphabetically?

来自分类Dev

How do I link boost to my program?

来自分类Dev

ServiceStack 和 Ormlite 将字符串“Don't do it”保存到 MySQL 时的编码问题

来自分类Dev

为什么我只得到部分图像?(libGDX,sprite,spriteBatch)

来自分类Dev

如何匹配用户单击和libGDX框架中的sprite对象位置

来自分类Dev

LibGDX:未注册名称为white的Drawable,NinePatch,TextureRegion,Texture或Sprite

Related 相关文章

  1. 1

    libGdx: Sprite is not drawn when there is a stage

  2. 2

    Libgdx Sprite不能平稳移动

  3. 3

    Sprite LibGDX中的视差滚动

  4. 4

    Libgdx Sprite不能平稳移动

  5. 5

    LibGdx-必须在Sprite中设置Sprite或Texture?

  6. 6

    libGdx:有舞台时不绘制Sprite

  7. 7

    LibGDX Flip 2D Sprite动画

  8. 8

    如何通过Sprite对象处理Libgdx纹理

  9. 9

    Libgdx Java Sprite大小问题

  10. 10

    Why don't my points display in Haskell OpenGL?

  11. 11

    Moved to the 5 GHz band but my old devices don't see it

  12. 12

    LibGDX Sprite批处理字体缩放比例不好

  13. 13

    控制和创建多个Sprite数组Java Libgdx

  14. 14

    Libgdx Sprite深度在Android上与在桌面上不同

  15. 15

    LibGDX batch.draw vs sprite.draw性能

  16. 16

    libgdx在运行时更改Image Sprite

  17. 17

    How do I parse my JSON with external middleware now that Express doesn't carry a body parser?

  18. 18

    How can we prevent that when I resize my window, my images move using HTML-CSS?

  19. 19

    libgdx,什么时候使用camera.position.set?

  20. 20

    How to select all elements that don't have a class or id?

  21. 21

    How to get perforce to pull only files that don't exist in workspace

  22. 22

    I don't see .bashrc file in my /home and /etc/skel direcories

  23. 23

    libgdx 模型实例位置在调用 camera.position.set 或 camera.lookat 后改变

  24. 24

    How do i sort my listview alphabetically?

  25. 25

    How do I link boost to my program?

  26. 26

    ServiceStack 和 Ormlite 将字符串“Don't do it”保存到 MySQL 时的编码问题

  27. 27

    为什么我只得到部分图像?(libGDX,sprite,spriteBatch)

  28. 28

    如何匹配用户单击和libGDX框架中的sprite对象位置

  29. 29

    LibGDX:未注册名称为white的Drawable,NinePatch,TextureRegion,Texture或Sprite

热门标签

归档