小编Kob*_*bol的帖子

设计游戏对象

我最近开始使用Microsoft XNA和C#开发一款适合自己娱乐的小游戏.我的问题是关于设计游戏对象和继承游戏对象的对象.我将把游戏对象定义为可以在屏幕上呈现的东西.所以为此,我决定创建一个基类,其中所有其他需要渲染的对象都将继承,称为GameObject.下面的代码是我制作的课程:

class GameObject
{
    private Model model = null;
    private float scale = 1f;
    private Vector3 position = Vector3.Zero;
    private Vector3 rotation = Vector3.Zero;
    private Vector3 velocity = Vector3.Zero;
    private bool alive = false;
    protected ContentManager content;

    #region Constructors
    public GameObject(ContentManager content, string modelResource)
    {
        this.content = content;
        model = content.Load<Model>(modelResource);
    }
    public GameObject(ContentManager content, string modelResource, bool alive)
        : this(content, modelResource)
    {
        this.alive = alive;
    }
    public GameObject(ContentManager content, string modelResource, bool alive, float scale)
        : this(content, modelResource, …
Run Code Online (Sandbox Code Playgroud)

c# oop xna

10
推荐指数
4
解决办法
5849
查看次数

标签 统计

c# ×1

oop ×1

xna ×1