Jump to content


Photo

Changing Resources Ingame


  • This topic is locked This topic is locked
5 replies to this topic

#1 J-Crew

J-Crew

    GMC Member

  • New Member
  • 9 posts

Posted 23 February 2008 - 12:44 PM

I want to have my game load with no sprites or music included at the beginning. But I want them to load as they are needed in the game. I believe the syntax for adding a sprite would be:
sprite_add(fname,imgnumb,precise,transparent,smooth,prelo
ad,xorig,yorig)
And for music:
sound_add(fname,kind,preload)

However, the problem I'm getting is with the first argument "fname". I don't really know what to put here to read my files. I have the files in the same folder as the game. Do I need to but an exact filename/path? Or does it have something to do with Including files using Global Game Settings?

Edited by J-Crew, 23 February 2008 - 12:45 PM.

  • 0

#2 wiredbomb0

wiredbomb0

    GMC Member

  • GMC Member
  • 367 posts
  • Version:GM8.1

Posted 23 February 2008 - 12:49 PM

well, it would probably (i think) to organize them a bit better. so music goes in a Music folder, sprites in a Sprite etc.

for the argument fname, you need to:

1(if the file is in the same place as the .exe): "music1.mp3"
2(if the file is in a folder): "Music/music1.mp3"

that should work!
  • 0

#3 J-Crew

J-Crew

    GMC Member

  • New Member
  • 9 posts

Posted 23 February 2008 - 12:59 PM

well, it would probably (i think) to organize them a bit better. so music goes in a Music folder, sprites in a Sprite etc.

for the argument fname, you need to:

1(if the file is in the same place as the .exe): "music1.mp3"
2(if the file is in a folder): "Music/music1.mp3"

that should work!

<{POST_SNAPBACK}>


Thanks alot. I'll give that a try! I got it to read it, and I assigned the values to a global variable to test and they worked. But is there a way to assign them to a sprite constant rather than a global variable, so that I can use them like a normal sprite?

Edited by J-Crew, 23 February 2008 - 01:11 PM.

  • 0

#4 ragarnak

ragarnak

    GMC Member

  • Retired Staff
  • 19468 posts
  • Version:GM8

Posted 23 February 2008 - 01:52 PM

But is there a way to assign them to a sprite constant rather than a global variable, so that I can use them like a normal sprite?

<{POST_SNAPBACK}>

Try this :D :
globalvar spr_MySprite;
spr_MySprite = sprite_add("spritefile.bin", 1, true, true, false, false, 0,0)
You can now use the "spr_MySprite" like you would use a sprite-resource name, though with two restrictions : they won't be selectable in drag-and-drop commands (as those only look in the resource-tree at the left), and the variable is not read-only (like resource names are).

Hope that helps.

Edited by ragarnak, 23 February 2008 - 01:53 PM.

  • 0

#5 J-Crew

J-Crew

    GMC Member

  • New Member
  • 9 posts

Posted 23 February 2008 - 04:13 PM

But is there a way to assign them to a sprite constant rather than a global variable, so that I can use them like a normal sprite?

<{POST_SNAPBACK}>

Try this :D :
globalvar spr_MySprite;
spr_MySprite = sprite_add("spritefile.bin", 1, true, true, false, false, 0,0)
You can now use the "spr_MySprite" like you would use a sprite-resource name, though with two restrictions : they won't be selectable in drag-and-drop commands (as those only look in the resource-tree at the left), and the variable is not read-only (like resource names are).

Hope that helps.

<{POST_SNAPBACK}>


Yeah that's about what I was doing. You just made it simpler. Thanks alot for the help. I think I've got this down pretty good.
  • 0

#6 ragarnak

ragarnak

    GMC Member

  • Retired Staff
  • 19468 posts
  • Version:GM8

Posted 23 February 2008 - 04:43 PM

Thanks alot for the help.

<{POST_SNAPBACK}>

You're wecome :D
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users