GameMaker object_set_sprite problem

S

Sowatt

Guest
Hello everyone!

I'm trying to achieve something very simple: changing the sprite of a created object.

So I have my object obj_face for which I would like to change the sprite (originally, this object has NO sprite).

I have a Parent object with the following code to create the object "obj_face" when I want:
Code:
instance_create_layer(vx+vw/12, vy+vh/1.3, "Layer_Text", obj_face);
Then, in a child object, I have the following:

Code:
if(diaCount = 1){
    global.nameToDisplay = "NPC 01";
    global.textToDisplay = "Text 01";
    object_set_sprite(obj_face, spr_face_npc_01);
    }

if(diaCount = 2){
    global.nameToDisplay = "NPC 02";
    global.textToDisplay = "Text 02";
    object_set_sprite(obj_face, spr_face_npc_02);
}
So, when diaCount = 1, I can see the right sprite (so it goes from NO SPRITE to spr_face_npc_01).

But for some (probably obvious) reason, the sprite of obj_face does not change when diaCount = 2 (but it works perfectly well for my global variables string text, so there's no problem with the diaCount variable).

Thanks a lot for your help and I hope that problem is understandable!! :)
 
S

Sowatt

Guest
Thanks a lot guys!
Works like a charm with sprite_index inside a with statement.
 
Top