returning image info
Blitz3D Forums/Blitz3D Programming/returning image info
| ||
Is it possible to "name" an image and thereby return that "name" if the mouse is clicked on the image??? |
| ||
Not that I'm aware of ... not really used the 2d side right enough. If you used a 3d quad then you could store the type handle of the button in the entity's name. |
| ||
@Rook, you could use a kind of HashTable to store the name of an image. Since you use Blitz3D, you may find useful a property read and write function, available in the code archive, by Ken Lynch: http://www.blitzbasic.com/codearcs/codearcs.php?code=820 With the above property bag, you can use SetProperty, by using the image ID as property name. Later you can, via GetProperty, address to that property (by using the image ID) to get the image name. In this way, you achieve an HashTable in a very easy - and effective - way. Alternatively: Since each image has an unique ID - which is returned by the function LoadImage - you can use store that ID in a string (or in a bi-dimensional array) or in a type structure, and associate it with anything you like. Example: type t_img_name field ID field name$ end type Global img_name.t_img_name ID = LoadImage("test.bmp") img_name = new t_img_name img_name\ID = ID img_name\name = "your image name here" . .A simple for..each loop through the type list, will check if the ID of the clicked image is in the list, and then get its name. Another example: mystring$ = ID + "#" + "your image name" . . ID = Parse(mystring,"#",1) name$ = Parse(mystring,"#",2) if ID = image_clicked_by_mouse then print "you clicked on the image named: " + name endifYou need an array of strings here, but you can use also a bi-dimensional array for your convenience. You have to loop through the whole list until your ID is matched, or the list is ended. You need a string parsing function too. Look in the code archive. Hope this has sense for you, Sergio. |
| ||
Semar, thank you... both the code and the link were very helpful... I havdn't thought of simply creating an array with the cards names in it... that would have been too easy which is why it slipped over my head! parse needs to be a command in Blitz. RZ |