• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Convert image to obj

C

Chuck Vork

Guest
Is there a way to convert image files to obj's during runtime?
 

YoSniper

Member
There's a way to load them as sprites, not objects. You can have an object that inherits the newly created sprite by setting its sprite_index value afterwards.

The function you want is probably sprite_add
 
C

Chuck Vork

Guest
If I can't do my above question, is there a way to load an extenal image file into an instance_create without converting it to an OBJ first?
 
If I can't do my above question, is there a way to load an extenal image file into an instance_create without converting it to an OBJ first?
As said above, you can use sprite_add() to load the image from disk. sprite_add() returns the new index for that sprite, which you can then assign to the sprite_index of the object you are creating.

Code:
var _loaded_sprite_index = sprite_add("player_5.png", 16, true, true, 0, 0);
var _iii = instance_create(x, y, obj_player);
_iii.sprite_index = _loaded_sprite_index;
 
Top