Page 1 of 1

Making all clones being drawn in a canvas

PostPosted: Sat Jul 11, 2009 8:27 am
by Zehper48
Is there a way I can make all clones of an actor bedrawn in a canvas without listing each individual clone?
Tell me if I am not being very clear
Thanks alot :D

Re: Making all clones being drawn in a canvas

PostPosted: Sat Jul 11, 2009 9:23 am
by skydereign
Not directly, but you can do this.
Code: Select all
Actor *
getCloneIdx (const char *cname, int cindex)    //g_GetCloneByIndex, its original name
{
    char buffer[50];
    sprintf(buffer,"%s.%i",cname,cindex);
    return(getclone(buffer));
}


Code: Select all
int i;
Actor * clone;
erase(0,0,0,1);
for(i=0;i<ActorCount("actorName");i++)
{
    clone = getCloneIdx("actorName", i);
    draw_from(clone.clonename, clone->x, clone->y, 1);
}


The xy coordinates will change for how you want it, but I think you can use screen_to_actor, or actor_to_screen, to set that up or your own variables.

What this does is go through all existing clones, by use of a for loop and the ActorCount function, and draws them. It uses each clone's xy, but this will probably not work without adjustment, otherwise you would not use draw.

Re: Making all clones being drawn in a canvas

PostPosted: Sat Jul 11, 2009 9:30 am
by Zehper48
thanks for replying fast, i dont know exactly how to use this :cry: but also is there a way to send an activation event to all clones? without listing them all?

Re: Making all clones being drawn in a canvas

PostPosted: Sat Jul 11, 2009 9:57 am
by skydereign
Sorry, forgot to explain that. The first code block would go into global code. The second one wherever you want to have the canvas event to draw the actors. I would think in its draw. To send an ActivationEvent, it would follow the same idea. It to requires the getCloneIdx

Code: Select all
int i;
Actor * clone;
for(i=0;i<ActorCount("actorName");i++)
{
    clone = getCloneIdx("actorName", i);
    SendActivationEvent(clone->clonename);
}


That code goes wherever you are sending the ActivationEvent from.

-Edit
On my previous post, there is a typo, it should be this.

Code: Select all
int i;
Actor * clone;
erase(0,0,0,1);
for(i=0;i<ActorCount("actorName");i++)
{
    clone = getCloneIdx("actorName", i);
    draw_from(clone->clonename, clone->x, clone->y, 1);
}

Again, this is for the drawing.