I need to create a map of Mix Music with integers to play certain clips when needed. Here’s what I have
AudioHandler.cpp
Code:
#ifndef RunnyMan__AudioHandler
#define RunnyMan__AudioHandler
#include
#include <SDL2/SDL.h>
#include <SDL2_mixer/SDL_mixer.h>
#include
class AudioHandler {
private:
std::map<int, Mix_Music* > clips;
public:
bool init();
bool addClip(const char *, int);
};
#endif /* defined(RunnyMan__AudioHandler) */
AudioHandler.h
Code:
#include “AudioHandler.h”
bool AudioHandler::init(){
if (Mix_OpenAudio(22050, AUDIO_S16, 2, 4096) != 0){
return 1;
};
return 0;
};
bool AudioHandler::addClip(const char * filename, int index){
Mix_Music * music = nullptr;
music = Mix_LoadMUS(filename);
clips[index] = music;
return true;
};
However, I keep getting
Code:
No viable overloaded ‘=’
Why?[/code][/quote]
2014-04-14 0:38 GMT+02:00 Plazmotech :
I need to create a map of Mix Music with integers to play certain clips
when needed. Here’s what I have
AudioHandler.cpp
Code:
#ifndef RunnyMan__AudioHandler
#define RunnyMan__AudioHandler
#include
#include
#include
#include
class AudioHandler {
private:
std::map clips;
public:
bool init();
bool addClip(const char *, int);
};
#endif /* defined(RunnyMan__AudioHandler) */
AudioHandler.h
Code:
#include “AudioHandler.h”
bool AudioHandler::init(){
if (Mix_OpenAudio(22050, AUDIO_S16, 2, 4096) != 0){
return 1;
};
return 0;
};
bool AudioHandler::addClip(const char * filename, int index){
Mix_Music * music = nullptr;
music = Mix_LoadMUS(filename);
clips[index] = music;
return true;
};
However, I keep getting
Code:
No viable overloaded ‘=’
Why?[/code][/quote]
Shouldn’t that be std::map<int, Mix_Music*>; ? I can’t see the template
args in your code.
Code looks good to me. What’s your compiler ?
That’s not how you use a templated type.
std::map <key_type, data_type, [comparison_function]>
std::map <string, char> grade_list;
grade_list[“John”] = ‘B’;
More for instance, on: http://www.cprogramming.com/tutorial/stl/stlmap.htmlOn Tue, Apr 15, 2014 at 1:58 AM, Plazmotech wrote:
mr_tawan wrote:
Code looks good to me. What’s your compiler ?
I’m using XCode 4
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org