Externally Loading Files
#1
Posted 12 October 2011 - 02:09 PM
#2
Posted 12 October 2011 - 02:24 PM
why not try to use this codes
sprite_replace(spr_player,'player.png',image_number,removeback,smooth,xorigin,yorigin)
background_replace(bck_floor,'floor.png',removeback,smooth)
Note:the files should be at the same directory where the game is...
#3
Posted 12 October 2011 - 03:01 PM
No they do not have to be in the same folder as the game it can be anywhere on the PCGood for you cause you have Pro,
why not try to use this codes
sprite_replace(spr_player,'player.png',image_number,removeback,smooth,xorigin,yorigin)
background_replace(bck_floor,'floor.png',removeback,smooth)
Note:the files should be at the same directory where the game is...
#4
Posted 12 October 2011 - 03:26 PM
No they do not have to be in the same folder as the game it can be anywhere on the PC
Good for you cause you have Pro,
why not try to use this codes
sprite_replace(spr_player,'player.png',image_number,removeback,smooth,xorigin,yorigin)
background_replace(bck_floor,'floor.png',removeback,smooth)
Note:the files should be at the same directory where the game is...
Edited by GraphicGamer, 12 October 2011 - 03:28 PM.
#5
Posted 12 October 2011 - 03:30 PM
...No they do not have to be in the same folder as the game it can be anywhere on the PC
Good for you cause you have Pro,
why not try to use this codes
sprite_replace(spr_player,'player.png',image_number,removeback,smooth,xorigin,yorigin)
background_replace(bck_floor,'floor.png',removeback,smooth)
Note:the files should be at the same directory where the game is...
They have to be in the same folder. But you can do something like this "/data/sprite.png"; If you want it to be in another folder.
#6
Posted 12 October 2011 - 04:02 PM
No, they don't. You actually said so yourself.They have to be in the same folder.
The directory it is in doesn't even have to be in the working directory or program directory. You just have to provide the whole path.
Edit: I recommend not having them in the same folder as the .exe, as it will make everything look messy. I usually go with subdirectories within the working one, named with something relevant to their function:
file = working_directory+"\Resources\Sprites\spr_player.png"
Edited by LOS.A, 12 October 2011 - 04:07 PM.
#7
Posted 12 October 2011 - 05:03 PM
Now back to the topic:
sprite_add(fname,imgnumb,removeback,smooth,xorig,yorig) Adds the image stored in the file fname to the set of sprite resources. Many different image file types can be dealt with. When the image is not a gif image it can be a strip containing a number of subimages for the sprite next to each other. Use imgnumb to indicate their number (1 for a single image). For gif images, this argument is not used; the number of images in the gif file is used instead. removeback indicates whether to make all pixels with the background color (left-bottom pixel) transparent. smooth indicates whether to smooth the edges. xorig and yorig indicate the position of the origin in the sprite. The function returns the index of the new sprite that you can then use to draw it or to assign it to the variable sprite_index of an instance. When an error occurs -1 is returned.
sprite_add_sprite(fname) Adds the sprite stored the file fname to the set of sprite resources. The file must be a .gmspr file that is saved in the sprite property form in GameMaker. As this file contains all sprite settings, no further arguments are required. The function returns the index of the new sprite that you can then use to draw it or to assign it to the variable sprite_index of an instance. When an error occurs -1 is returned.
There are functions like these for backgrounds and sounds. You can look them up in the game maker manual.
It is better to load the files externally and the main reason is that the game loads much faster.
Hope this was helpful : )
#8
Posted 12 October 2011 - 05:52 PM
#9
Posted 13 October 2011 - 01:43 PM
Here's my code at the create event that fit's perfectly.
john_stand=sprite_add_sprite("spr_john_stand.gmspr")
john_walk=sprite_add_sprite("spr_john_walk.gmspr")
john_punch=sprite_add_sprite("spr_john_punch.gmspr")
floorjump=floor(sprite_height/2)+15 ;
image_speed= 0.3;
gravity=1;
standsprite=john_stand ;
walksprite= john_walk;
swordsprite=john_punch;
But i wonder if i can use the sprite_replace_sprite(ind,fname) in my code to be more efficient in my memmory. how to i use index to change the ind in the sprite_replace_sprite.
#10
Posted 15 October 2011 - 03:58 AM
Of course teach him the basic and let him found out and learn the rest for himself and gain knowledge...
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











