problem solved.....
i have added a new empty sprite bank, but it don't have any sprite in it
now i added a sprite (with a single frame) and it works
Code: Select all
//add an empty sprite bank
gui::IGUISpriteBank* sb = guienv->addEmptySpriteBank("my button");
video::ITexture* texture_up = driver->getTexture("button_up.png");
video::ITexture* texture_down = driver->getTexture("button_down.png");
video::ITexture* texture_over = driver->getTexture("button_over.png");
//add textures into sprite bank
sb->addTexture(texture_up); //0
sb->addTexture(texture_down); //1
sb->addTexture(texture_over); //2
//add sizes
sb->getPositions().push_back(core::rect<s32>(core::position2di(0,0), texture_up->getOriginalSize()));
sb->getPositions().push_back(core::rect<s32>(core::position2di(0,0), texture_down->getOriginalSize()));
sb->getPositions().push_back(core::rect<s32>(core::position2di(0,0), texture_over->getOriginalSize()));
//add sprites
gui::SGUISprite sprite;
gui::SGUISpriteFrame sframe;
sprite.Frames.push_back(sframe);
sprite.Frames[0].rectNumber = 0;
sprite.Frames[0].textureNumber = 0;
sb->getSprites().push_back(sprite);
sprite.Frames[0].rectNumber = 1;
sprite.Frames[0].textureNumber = 1;
sb->getSprites().push_back(sprite);
sprite.Frames[0].rectNumber = 2;
sprite.Frames[0].textureNumber = 2;
sb->getSprites().push_back(sprite);
//use the sprite bank
button->setSpriteBank(sb);
button->setSprite(gui::EGBS_BUTTON_UP, 0, video::SColor(255, 255, 255, 255), false);
button->setSprite(gui::EGBS_BUTTON_DOWN, 1, video::SColor(255, 255, 255, 255), false);
button->setSprite(gui::EGBS_BUTTON_MOUSE_OVER, 2, video::SColor(255, 255, 255, 255), false);
button->setSprite(gui::EGBS_BUTTON_MOUSE_OFF, 0, video::SColor(255, 255, 255, 255), false);
however, another problem comes.........
both
EGBS_BUTTON_MOUSE_OVER and
EGBS_BUTTON_MOUSE_OFF are not usable
the button changes when it's clicked, but it doesn't change when the cursor moves over it