我有两个调用相同父函数的子类。
一个工作正常,但它的第二个调用不能越界al_convert_mask_to_alpha
。
我又一次被迷惑了。
有谁知道为什么会发生这种情况?
下面的函数是它们都调用的函数。与上面两者的声明。
Monster* the_monster = new Monster("chard", 10, 10, "assets/monstertrans.bmp");
Hero* the_hero = new Hero(1, "Player", 20, 20, "assets/hero.bmp");
the_monster->Display();
the_hero->Display();
void Creature::Display(void)
{
//creating the bitmap
al_init_image_addon(); //allegro image addon
//FORGETTING THIS LINE WAS A SILLY IDEA!!!!
creature_bit = al_load_bitmap(m_filename.c_str());
al_convert_mask_to_alpha(creature_bit, al_map_rgb(255,0,255));
al_draw_bitmap(creature_bit, m_xpos, m_ypos, 0);
if (!creature_bit)
{
cout << "creature creation failed!" << endl;
cout << "Any key to exit" << endl;
_getch();
}
}