ent_create

Posted By: Frits

ent_create - 03/20/07 14:43

When I create a sprite with;
Code:

string sign; // declare an empty, unlimited string

funtion blabla()
{
..............
str_cpy(sign," "); // make the string empty
str_cpy(sign,"abc.bmp"); // set sprite in sign
ent_create(sign,vector(x,y,z)); // place sprite on screen
..............
..............
}


that works perfect, but now I want to remove the sprite again because I want to create and show an other sprite in 'sign'.
I tried it with ent_remove, but that does not work, it has to be an entity.

Does anyone know how I can do that?
Posted By: vlau

Re: ent_create - 03/20/07 14:51

ent_remove(ENTITY* entity).

You need a pointer to your sprite (entity).
Posted By: aztec

Re: ent_create - 03/20/07 14:52

Quote:


Code:

string sign; // declare an empty, unlimited string
entity* to_delete;

funtion blabla()
{
..............
str_cpy(sign," "); // make the string empty
str_cpy(sign,"abc.bmp"); // set sprite in sign
to_delete =ent_create(sign,vector(x,y,z)); // place sprite on screen
..............
..............
}







later then just call ent_remove(to_delete);
hope this helps
Posted By: Frits

Re: ent_create - 03/20/07 15:15

Thanks guys for the quick response.
I changed the script in;
Code:

string sign; // declare an empty, unlimited string
entity* sign_sprite;

funtion blabla()
{
..............
ent_remove(sign_sprite); // remove previous sprite
str_cpy(sign," "); // make the string empty
str_cpy(sign,"abc.bmp"); // set sprite in sign
sign_sprite=ent_create(sign,vector(x,y,z)); // place sprite on screen
..............
..............
}


but then ofcource I get an error, because the entity is empty with the first call.
How can I check if the entity has a value?
(like with a var fisttime 'if(firsttime==0)' or something like that?)
Posted By: aztec

Re: ent_create - 03/20/07 15:18

why do you delete something before you create it?
Posted By: Slin

Re: ent_create - 03/20/07 15:18

if(sign_sprite)
{
ent_remove(sign_sprite);
}
Posted By: Frits

Re: ent_create - 03/20/07 15:33

Thanks Slin, I think I am working to long, not thinking straight anymore. How simple can the solution be.

Aztec, this is explained in my initial post, 'I want to remove the sprite again because I want to create and show an other sprite in 'sign'.
So, I can't set the ent_remove at the end of the function, first remove the previous and than create a new one.
© 2023 lite-C Forums