声明变量的变量?

时间:2015-03-15 23:23:26

标签: c++ directx

我正在使用鼠标输入在DirectX中移动精灵。

我试图使用教授的这个例子,但是你看到了我的注释错误:

// Mouse
float mouseSensitivity = 2000.0f;
spriteObj[5].position.x += (mouseState.lX * mouseSensitivity) * dt;//Error  1   error C2228: left of '.position' must have class/struct/union   //Error 2   error C2228: left of '.x' must have class/struct/union  

我正在尝试初始化" spriteObj [5] .position.x"的变量位置和x,但是如何将x声明为作为spriteObj [5]成员的位置成员?

1 个答案:

答案 0 :(得分:0)

对不起,我在这里留下了一个暗淡的,无疑的问题。解决它让我觉得很愚蠢,哈哈。错误确实解释了这一切,我初始化没有结构来保存位置数据。这是解决问题的完成结构。

struct SpriteObject
{
D3DXVECTOR3 position;
// Translation
float rotation;
// Z rotation
float scale;
// Uniform scaling (x and y value the same)
D3DCOLOR color;
// Color modulation
};

相关问题