Rectangle and Circle collision detection

前端 未结 2 459
礼貌的吻别
礼貌的吻别 2021-01-22 03:43

I am trying to do collision detection between a rectangle and a circle. I came up with this method:

-(BOOL) isCollidingRect:(CCSprite *) spriteOne WithSphere:(CC         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 04:35

    You can use CGRectIntersectsRect to achieve this.

    -(BOOL) isCollidingRect:(CCSprite *) spriteOne WithSphere:(CCSprite *) spriteTwo {
        return CGRectIntersectsRect([spriteOne boundingBox],[spriteTwo boundingBox]);
    }
    

    It is not pixel perfect but as i understand that is not necessary in this case.

提交回复
热议问题