所以我一直在關注使用SFML開發C++遊戲的視頻教程,並且遇到錯誤。我在這個網站上描述了這個問題: http://en.sfml-dev.org/forums/index.php?topic=21589.0 (我知道我知道分享鏈接並不好,但我不打算在不久的將來刪除它。) 對於突出顯示的錯誤是: C :/ Program Files/CodeBlocks/MinGW/lib/gcc/mingw32/4.9.2/include/C++/bits/stl_map.h:504:59:錯誤:沒有匹配函數調用'Animation :: Animation()'沒有匹配的函數調用'Animation :: Animation()
我認爲是衝突的線是: std :: map animList;
我的動畫類,它的功能是這樣的: 類動畫,然後公衆然後構造:
// Animation class
class Animation
{
public:
std::vector<IntRect> Frames, Frames_flip;
float CurrentFrame, Speed;
bool Flip, IsPlaying;
Sprite sprite;
Animation(Texture &t, int x, int y, int w, int h, int Count, float speed, int Step)
{
Speed = speed;
sprite.setTexture(t);
CurrentFrame = 0;
IsPlaying = true;
Flip = false;
for (int i = 0; i < Count; i++)
{
Frames.push_back(IntRect(x+i*Step,y,w,h));
Frames_flip.push_back(IntRect(x+i*Step+w,y,-w,h));
}
}
void Tick(float Time)
{
if (!IsPlaying) return;
CurrentFrame += Speed * Time;
if (CurrentFrame> Frames.size())
CurrentFrame -= Frames.size();
int i = CurrentFrame;
sprite.setTextureRect(Frames[i]);
if (Flip) sprite.setTextureRect(Frames_flip[i]);
}
};
// Animation Manager Class
class AnimationManager
{
public:
String CurrentAnim;
std::map<String, Animation> animList;
AnimationManager()
{
}
void Create(String Name, Texture &t, int x, int y, int w, int h, int Count, float Speed, int Step)
{
animList[Name] = Animation(t,x,y,w,h,Count,Speed,Step);
CurrentAnim = Name;
}
void Draw(RenderWindow &window, int x = 0, int y = 0)
{
animList[CurrentAnim].sprite.setPosition(x,y);
window.draw(animList[CurrentAnim].sprite);
}
void Set(String name) { CurrentAnim = name; }
void flip (bool b) { animList[CurrentAnim].Flip = b; }
void tick(float Time) {animList[CurrentAnim].Tick(Time); }
void pause() {animList[CurrentAnim].IsPlaying = false;}
void play() {animList[CurrentAnim].IsPlaying = true;}
};
_The行多數民衆贊成使得衝突我認爲是:std :: map animList; _該行幾乎不會出現在您的代碼中 – Tas
您是否檢查了鏈接,還有更多的代碼。 –
不,你檢查[問]嗎?也就是說,創建一個[mcve] – Tas