-1

So basically i have a sprite that I can move around with it being touched within its own boundaries.

    if(v3.x >= spear.b2body.getPosition().x - spear.getWidth()/2 && 
           v3.x <= spear.b2body.getPosition().x + spear.getWidth()/2 &&
           v3.y >= spear.b2body.getPosition().y - spear.getHeight()/2 && 
           v3.y <= spear.b2body.getPosition().y + spear.getHeight()/2 ){

//sprite has been touched
}

This works great and i could move it around while onTouchDragged.

BUT If i apply an angle to the sprite, well the boundaries don't follow, they stay the same as if the sprite was still at an angle of 0.

So yeah MATH... If you can help me out here or point me in the right direction it would be greatly appreciated.

Oh yeah i should also mention that the sprite has a rectangular shape (161 x 16)

im using libgdx imported with box2d

Marke
  • 189
  • 4
  • 13

1 Answers1

0

Well i found my answer i'm using libgdx didn't see that there was a function that does this already using.

sprite.getBoundingRectangle.contains(x,y)

Marke
  • 189
  • 4
  • 13