Page 1 of 1

Re-position Actor before Path assignment

PostPosted: Mon Jun 02, 2008 5:34 pm
by akhad
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 ?

Re: Re-position Actor before Path assignment

PostPosted: Sat Jun 07, 2008 5:19 am
by DST
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.

Re: Re-position Actor before Path assignment

PostPosted: Sat Jun 07, 2008 8:57 am
by akhad
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.

Re: Re-position Actor before Path assignment

PostPosted: Sat Jun 07, 2008 9:08 am
by DST
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