V
VansiusProductions
Guest
Hi guys,
For my game i am implementing a system where the user can download texture packs to change how the game looks. Here's some code from the parent object:
Now each children object will get its name that corresponds to the file names (the objects are named like obj_ball, so nameTemp2 will be ball). Then in sprfile it searches for the file in the directory, if such file exists, it will add it to the game and change its sprite index,
However for some objects, when sprfile doesn't find the file, it still changes its sprite index so it becomes empty. How do i prevent this?
For my game i am implementing a system where the user can download texture packs to change how the game looks. Here's some code from the parent object:
Code:
nameTemp = object_get_name(object_index)
nameTemp2 = string_replace(nameTemp, "obj_", "")
sprfile = working_directory + "\packs\test\" + nameTemp2 + ".png"
if !(is_undefined(sprfile)) {
if !(sprite_exists(1)) index = 1
if !(sprite_exists(2)) index = 2
spr = sprite_add(sprfile,index,false,false,0,0)
sprite_index = spr
}
However for some objects, when sprfile doesn't find the file, it still changes its sprite index so it becomes empty. How do i prevent this?