problems with cloning codes

Game Editor comments and discussion.

problems with cloning codes

Postby Fojam » Fri Nov 13, 2009 9:00 pm

ok, so I have clones for a few actors, but when I write code for the clones, it says there are errors... can someone help me?

Code: Select all
medium_ant_down.yvelocity = medium_ant_down.yvelocity - 3;
medium_ant_left.xvelocity = medium_ant_left.xvelocity + 3;
medium_ant_right.xvelocity = medium_ant_right.xvelocity - 3;
medium_ant_up.yvelocity = medium_ant_up.yvelocity + 3;
small_ant_down.yvelocity = small_ant_down.yvelocity - 3;
small_ant_down.1.yvelocity = small_ant_down.1.yvelocity -3;
small_ant_down.2.yvelocity = small_ant_down.2.yvelocity -3;
small_ant_left.xvelocity = small_ant_left.xvelocity + 3;
small_ant_left.1.xvelocity = small_ant_left.1.xvelocity + 3;
small_ant_right.xvelocity = small_ant_right.xvelocity - 3;
small_ant_right.1.xvelocity = small_ant_right.1.xvelocity - 3;
small_ant_right.2.xvelocity = small_ant_right.2.xvelocity - 3;
small_ant_up.yvelocity = small_ant_up.yvelocity + 3;
small_ant_up.1.yvelocity = small_ant_up.1.yvelocity + 3;
small_ant_up.2.yvelocity = small_ant_up.2.yvelocity + 3;
small_ant_up.3.yvelocity = small_ant_up.3.yvelocity + 3;
small_ant_up.4.yvelocity = small_ant_up.4.yvelocity + 3;



I want the main actor's clones to do exactly what it does. I'm not sure what is wrong... according to the code, it should work.
The error says that there is an error on every line of code that uses one of the clones. it says there is an expected ; but I already have one.

can someone help me?
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: problems with cloning codes

Postby jimmynewguy » Fri Nov 13, 2009 9:53 pm

i'm sure there's a way to do this with arrays, but i really don't understand them :lol: the easiest way and the way i would do is to use switch. It's kind of like a whole bunch of if(==) without typing it each time, since actor.cloneindex.variable doesn't work
Code: Select all
switch(cloneindex)//each case is the cloneindex
{
case 0: xvelocity=-3;//kind of like if(cloneindex==0){
break;//end the if. kind of like the ending bracket or }
}


you'd have to do this with each different actor if you get what I'm saying, since you have different kinds of actors. or just have an event on the actor that changes it's yvelocity instead of using it's name.
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: problems with cloning codes

Postby skydereign » Sat Nov 14, 2009 8:02 am

The problem with your code is that you can't do something like this.
Code: Select all
actorname.actorcloneindex.actorvariable;

Pretty much you can't get a clone, using dot, and then use another dot to specify with actor variable. You would need to use something like getCloneIdx. If you are using an Actor*, then you can do things with clone specific actor variables.
Code: Select all
Actor* currentclone = getclone("medium_ant_down.1");
// This gets your clone, allowing for direct access to the variables such as yvelocity
currentclone->yvelocity=currentclone->yvelocity + 3;


This is just a small example of Actor*, if you do want me to explain this than I can, but you might be able to use jimmynewguy's suggestion. The explanation I showed here was just to explain the concept, it is not the most optimal given your circumstance. Also it seems you can use parenting, I don't know exactly what you are trying to do... Anyways, I would be glad to help out if need be.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: problems with cloning codes

Postby Fojam » Sun Nov 15, 2009 10:12 pm

do you think that you can get makslane to change that? it is kind of annoying.
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: problems with cloning codes

Postby skydereign » Mon Nov 16, 2009 4:54 am

Well that is a problem with C/C++ in general then, as actor variables are pretty much C++, it may be possible, but it would get really weird in coding. Not sure how you would do it cleanly, I guess if it ever sees a actorname.cloneindex.actorvariable, it could find the way, but you can also write a function that does it for you. Most of the time if there is a custom function that you can write, then it is better to do that... If you want, I can post a similar working function.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron