need help with clones! swap positions.

Talk about making games.

need help with clones! swap positions.

Postby sonicfire » Sun Mar 20, 2011 10:01 pm

hi folks! :)

i really need help! i have 10 actors (clones!) on screen, all from one baseactor, called diamond.
they only differ in animations (red, blue, green and so on...).

now when i click one "diamond" (one clone), and then another, i want these two to swap / exchange positions on screen.
so basically diamond1 = diamond2 x and y and diamond2 = diamond1.x and y.

however i cannot get this to work. i tried something like this in mouse down event:
Code: Select all
Actor *a,*b;

a = getclone(diamond);
sourcex = a->x;
sourcey = a->y;


and within second mouseclick:
Code: Select all
b = getclone(diamond);
targetx = b->x;
targetx = b->y;
// swap positions
a->x = targetx;
a->y = targety;
b->x = sourcex;
b->y = sourcey;


the code is not complete here, it´s just to show what i´m trying to do and what i came up with so far.
however this doesnt work, the first diamond jumps to the "target" diamond , but this one doesnt jump back to where
i have first clicked :-(

can anybody help me to achieve this somehow? whats a good way to do it?
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: need help with clones! swap positions.

Postby skydereign » Sun Mar 20, 2011 11:12 pm

Try this. I originally had just a global Actor*, but it had problems setting the actor's xy... so I just used getCloneIdx and had a variable diamondIdx.
Attachments
switch.ged
(4.11 KiB) Downloaded 89 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: need help with clones! swap positions.

Postby sonicfire » Sun Mar 20, 2011 11:35 pm

absolutely amazing. have to learn from this. thank you so much! +1 :D
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: need help with clones! swap positions.

Postby Scorpion50o1 » Mon Mar 21, 2011 1:08 am

making a bejeweled kinda game i see?
OMG IM SO BORED <(^^)> (>^^)> (>^^)>
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
User avatar
Scorpion50o1
 
Posts: 246
Joined: Fri Apr 17, 2009 1:07 am
Location: TX
Score: 8 Give a positive score

Re: need help with clones! swap positions.

Postby sonicfire » Mon Mar 21, 2011 1:49 pm

trying to, yes :) but now i realize it is WAY harder than i thought :lol:
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest