Peer-to-Peer Forum

 

Login Register    
How to Set an Image at a Given Index in vpOverlay2DImage
Posted: 04 August 2010 10:08 AM  
Newbie
Rank
Total Posts:  23
Joined  2007-11-07

I am trying to design a custom push button control class using vpOverlay2DImage.

I can add several bitmaps to my vpOverlay2DImage object representing my button in its various states ie
Normal image at, say, index 0
Mouse Over image at index 1
Pressed image at index 2
Disabled image at index 3

How can I explicitly set the vpoverlay_2d_image to display an image at a particular index in the list (ie depending on the user input)?

I have looked in the documentation and in vpoverlay_2d_image.h for how to do this, but I haven’t found out how, yet.

Any suggestions would be appreciated.

 
Posted: 25 August 2010 03:32 PM   [ # 1 ]  
Member
RankRankRank
Total Posts:  78
Joined  2009-01-15

vpOverlay2DImage method addImageFile(const char* filename, int loc = -1); should work.  The second parameter “loc” is the index you specify for the image you are adding.  When I used this function I left the second parameter as -1 and just controlled the order in which I added my images. 

EDIT: Sorry I just read your post more closely.  You weren’t asking about loading but instead about displaying.  I do not see any provision for what you are asking.  The multiple images for this class act more like a sprite sheet than anything else.  You supply it the images and a delay time and it handles drawing each of them in the order in which they were loaded.

If it were me I would create separate vpOverlay2DImage instances, one for each button image instead of trying to put all the images into one vpOverlay2DImage instance.  Then I would simply enable and disable them only showing the one I want, disabling the rest.

Steve