Re-position Actor before Path assignment

Non-platform specific questions.

Re-position Actor before Path assignment

Postby akhad » Mon Jun 02, 2008 5:34 pm

I've come across this small problem while moving some objects in a `dropping` style in a game I'm working on. Basically I need to move the Actor sprite up, say by 100 pixels, then attaching a path that moves the Actor back down, ending with a `bounce`motion. The path works perfectly but I can't reposition the actor AND assign the Path. Here's an example...

Make a basic Path that will move the Actor down about 100 pixels, call it `testpath`. Create an Actor and place it at screen centre (0,0). Add a MouseDown event to the actor and in the script put-

test.y -=200;

Run it and the Actor moves up by 200 pixels.Fine. Now put-

ChangePath("test", "test", Y_AXIS);
after the above code. Now I expected (hoped) that the Actor would move up 100 pxls and then start back down on the Path.
But it jumps straight to the Path movement, skipping the Y repositioning code. I guess the Path is grabbing the co-ordinates as the script is run, and as Paths are relative to the Actor it's somehow overriding the Y position line. Is this normal ? And is there a way around it within one single Actor script ?
User avatar
akhad
 
Posts: 43
Joined: Tue Jan 16, 2007 1:59 pm
Location: U.K
Score: 0 Give a positive score

Re: Re-position Actor before Path assignment

Postby DST » Sat Jun 07, 2008 5:19 am

I wouldn't mix paths with xy. pick one or the other.
i'm kinda curious why you have an instant y-=200; will that look right?
He goes up instantly but moves down slowly?

Pick one or the other. Either make a path that goes both directions and use it, or use yvelocity.

on the event:
Code: Select all
spos=y-200; canmove=1; yvelocity=-20;

now in draw actor;
Code: Select all
if (canmove==1){
if (y>spos){yvelocity=20;}
}


and on hitting the floor or something like that, canmove and yvelocity both become 0 again.

Thats just one way.

You could just make a path that goes up, then down again.

There are many ways.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Re-position Actor before Path assignment

Postby akhad » Sat Jun 07, 2008 8:57 am

Thanks for that DST. The reasoning behind this was after playing around with some block movements for a planned game.
A quick description would be...imagine 3 blocks stacked vertically. A mouse click on the bottom block would take it away, placing it on top of the the other two blocks, then the next two fall down by 1 block. The just-moved top block then drops on top of the bottom two block, and by using a path that has a bounce motion at the end it gives it a somewhat `physics` like appearance. Tie the path to all three blocks in this routine and they all appear to `bounce` as they drop. It was just a quick workaround instead of using a proper pixel based solution.
User avatar
akhad
 
Posts: 43
Joined: Tue Jan 16, 2007 1:59 pm
Location: U.K
Score: 0 Give a positive score

Re: Re-position Actor before Path assignment

Postby DST » Sat Jun 07, 2008 9:08 am

Oh that makes way more sense. Use an array for that. totally use an array for puzzle games.

Arrays rule for puzzle games! Replaces all collisions and collision free's. Use arrays.

Totally use arrays. totally.

Use arrays. Totally.

LOL
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron