Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Calling Media by name rather than number

Author
Message
Baggers
22
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 15th May 2005 10:27
<Cheesy advertising voice on> Hi, do you ever find yourself in that situation where your swamped with numbers of objects, images and sounds and just wish you could call them by a name rather than a number ?
Well now you can !
<Cheesy advertising voice off>

Ok enough of that, this is a simpel system that sacrifices a little speed for ease of programming.

To start with, include the routines in the codebox somewhere in your code.

The first step then is to put...
Gosub SetupMediaNaming
...somewhere at the beginning of your program.

then the system is ready. You can use the following commands


MakeObj(FileName$,name$)
Where 'FileName$' is the file path of the object
and Name$ is the name you would like to use instead of a number

You use all other object commands just like normal except you use a command and name rather than a number. eg:
MakeObj("Ball.x","Ball")
Position Object ObjNum("Ball"),10,0,20

MakeImg(FileName$,name$)
Where 'FileName$' is the file path of the image
Name$ is the name you would like to use instead of a number
and 'Tex' is the texture flag

as above you use a command instead of a number
MakeImg("TitleLogo.jpg","Logo",1)
Sprite 1,10,20,ImgNum("Logo")

The same method goes for sounds, except i have added a few more commands with sound. Not for a majorly important reason...i think i just fancied them at the time !




Hope someone finds this useful
Enjoy !

p.s. Any problems, bugs, criticism, compliments....just post !

Kohaku
22
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 15th May 2005 23:54
That's cool, but wouldn't a system like this be slightly simpler?



You are not alone.
Baggers
22
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 16th May 2005 00:13
Aye, true but then you have to set up the varible for each piece of media...this way its just a name.

RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 16th May 2005 17:24
Hey Baggers. I am very interested in this type of stuff. I'd ultimately like to set up DBPro functionality similar to VB, in regards to objects. For example, in VB you can name objects, like you have here. I'd also like to be able to do something like this;



To my point. Did you know you could do stuff like this?



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
TEH_CODERER
22
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 16th May 2005 20:07
This is very similar to what I did for my button example. Each button was given a name you could call it by.

Login to post a reply

Server time is: 2026-07-03 05:01:20
Your offset time is: 2026-07-03 05:01:20