Making all clones being drawn in a canvas

Non-platform specific questions.

Making all clones being drawn in a canvas

Postby Zehper48 » Sat Jul 11, 2009 8:27 am

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
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Re: Making all clones being drawn in a canvas

Postby skydereign » Sat Jul 11, 2009 9:23 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Making all clones being drawn in a canvas

Postby Zehper48 » Sat Jul 11, 2009 9:30 am

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?
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Re: Making all clones being drawn in a canvas

Postby skydereign » Sat Jul 11, 2009 9:57 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron