我想知道如何创建HUD.我目前拥有在设定坐标处绘制到屏幕的健康,法力和经验栏.这样做的缺点是,当相机平移条纹时,它们会保持在设定的坐标位置,我希望它们可以调整到视口,或者不受位置的影响而只是简单地绘制到屏幕上.
编辑我设法使用相机的x和y坐标调整HUD.我已经为绘制HUD创建了一个单独的类,但现在它们没有调整.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using GameOne.Components;
namespace GameOne.GameScreens
{
public class HUD : BaseGameState
{
Player player;
Texture2D HealthBar;
Texture2D HealthBarPositive;
Texture2D HealthBarNegative;
Texture2D ManaBar;
Texture2D ManaBarPositive;
Texture2D ManaBarNegative;
Texture2D ExpBar;
Texture2D ExpBarPositive;
int CurrentHealth = 100;
int CurrentMana = 45;
int CurrentExp = 0;
public HUD(Game game, GameStateManager manager)
: base(game, manager)
{
player = new Player(game);
}
public void LoadContent()
{
base.LoadContent();
HealthBar = Game.Content.Load<Texture2D>(@"GUI\healthBar");
HealthBarPositive …Run Code Online (Sandbox Code Playgroud)我有一个程序从文件中读取并将项目存储在队列中然后将它们打印出来.我从valgrind得到这个:
HEAP SUMMARY:
in use at exit: 302 bytes in 14 blocks
total heap usage: 30 allocs, 16 frees, 1,230 bytes allocated
302 bytes in 14 blocks are definitely lost in loss record 1 of 1
at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
by 0x372167FB41: strdup (strdup.c:43)
by 0x400A6A: addtoqueue(main.c:30)
by 0x400B5A: addfiletoqueue(main.c:45)
by 0x400C27: main (main.c:62)
LEAK SUMMARY:
definitely lost: 302 bytes in 14 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 0 …Run Code Online (Sandbox Code Playgroud)