pulpcore

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: Problem with controlling a Sprite moving along the Path Troy Cox Fri Jun 12 21:00:20 2009

Omar

I've updated this sample as well as the source to implement outputting
the image number to use.
It's easier than a case statement.

Anyone is free to use the sprite and code. I release them to the
public domain.

-Troy

On Jun 11, 8:14 pm, Troy Cox <[EMAIL PROTECTED]> wrote:
> Omar,
>
> Based on our off-line discussion, I have taken your path and created a
> sprite that follows it.
>
> Source here:http://getgamesforfree.com/pulpcore/Omar/OmarPathSource.zip
> Example here:http://getgamesforfree.com/pulpcore/Omar/
>
> If you need to switch images when the angle changes,
> It would be very simple to select the image in a case statement using
> mod
>
> int a = myRandomPath.getAngle(position) % 45; //should yield 8
> directions ??
>         switch (a) {
>             case 0:
>                 image = image1; //or whatever
>                 break;
>             case 1:
>                 image = image2;
>                 break;
>             case 2:
> .....and so on....
>
> -Troy
>
> On Jun 9, 6:55 pm, omar <[EMAIL PROTECTED]> wrote:
>
> > Thank you, David. I'll try to check the direction while the sprite is
> > moving.
>
> > And excuse me for one more question : do I have to extends
> > pulpcore.math.Path to get each joinpoint on the path? Because I'm also
> > wondering if i could use the contains(x,y) to check whether the sprite
> > reaches the joinpoint.
>
> > On Jun 10, 12:24 am, David Brackeen <[EMAIL PROTECTED]> wrote:
>
> > > Good question. There's no alert when the sprite hits a joint. At the 
> > > moment
> > > the only way to accomplish this is keep track of the sprite's previous
> > > location, check the angle the current location and the old one, and change
> > > the image based on the angle.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"PulpCore" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pulpcore?hl=en
-~----------~----~----~----~------~----~------~--~---