Simple gun in cocos2d+box2d game

前端 未结 1 866
Happy的楠姐
Happy的楠姐 2020-12-01 20:31

I\'m newbie in box2d. Can you help me? I want to make gun (touch, move, stopped, ball flew). I make detection and rotation of gun, but I can\'t make popping of ball. How ca

相关标签:
1条回答
  • 2020-12-01 20:52

    The easiest way is to look at the direction the gun is pointing when you define the body, and use GetWorldVector to see how it has changed. For example if the gun is pointing directly upwards when you create the body, this would be the direction (0,1). Then you can use GetWorldVector at any time to get the current direction of that vector in world coordinates:

    body->GetWorldVector( b2Vec2(0,1) );
    
    0 讨论(0)
提交回复
热议问题