pulpcore

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

Re: Problem with controlling a Sprite moving along the Path Troy Cox Mon Jun 15 21:00:39 2009

You are 100% correct. And, if you examine the code you'll see that I
am just rotating the sprite, as you suggest.

The real deal was that Omar said he wasn't able to get any output for
the angle via the position on an svg path

Omar was wanting code to select different sprites based on the angle
of travel. So, the text is displaying a number based on the angle that
one could use to select different sprites.

The numbers are all that was important.

The sprite was simply displaying the position. Sorry for the
misdirection--my bad.


On Jun 15, 10:22 pm, Will Jordan <[EMAIL PROTECTED]> wrote:
> This might sound like an obvious question, but...
>
> Is there any reason why you chose not to just rotate the sprite rather
> than use a fixed set of pre-rotated sprite images? One possible case
> where pre-rotated images would seem necessary is if there's some sort
> of fixed unidirectional shading or isometric view applied to the
> image, but the sprite in your game looks completely top-down, in which
> case you could just adjust the angle of the sprite automatically using
> moveAndRotate as in the PathMotion example...
>
> On Jun 12, 8:01 pm, Troy Cox <[EMAIL PROTECTED]> wrote:
>
> > 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
-~----------~----~----~----~------~----~------~--~---