On Sun, May 6, 2012 at 2:50 PM, Jason <[email protected]> wrote:

> I'm writing a little game in cocos2d, trying to use the Bezier Action
> and Bezier path to make a Missile fired from a Capitol Ship the
> missile fly at the Mother Ship in a cool, loopy kinda way.
>
> My problem seems to be what I think is a position isn't what Bezier
> thinks is a position. I give it the Mothership position, and the
> Missile starting position (wherever its Capitol Ship is at the time) ,
> and tell the Missile to make it's way to the Mothership.
>
>
If all the entities are direct childs of a Gamelayer or some other node,
then a Bezier from missile.position (at spawn time) to mothership.position
(at spawn time) should provide a travel path from missile.position to
mothership.position.

If thats not true (by example, if missile is child to capitol_ship) then
you have to do some coordinate changes: all the points in the bezier must
be in the same coordinate space.
There it can be handy the CocosNodes methods  point_to_world,
point_to_local


> However, the Bezier Path seems to think 0, 0 is where ever the Missile
>  has spawned, not absolute position on the screen.


> How can I get the Bezier Path to take absolute position? Here's the
> bit of code from the Missile class
>
>    def hitTarget(self):
>        tx, ty = self.target.position
>        mx, my = self.position
> # this bit of code makes the missile do weird things
> #        path = BezPath( (mx, my), #first point
> #                  (tx, ty), #end point
> #                  (mx-10, my-20), #second point
> #                  (mx-20, my-30)) #third
>
> #this bit of code makes the Missile spawn correctly, but will I have
> to calculate the relative position
> #of the mother ship to make it hit?
>        path = BezPath( (0, 0), #first point
>                  (0, 0), #end point
>                  (-10, -20), #second point
>                  (-20, -30)) #third
>
>        self.do(BezAction(path, 2 ))
>
> --
>


You need to clarify the parent - child relationship to asses the correctnes
of your code

claudio

--

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" 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/cocos-discuss?hl=en.

Reply via email to