开发者

Creating 2D Bounding Box's

how would I create a bounding box a开发者_Python百科round a object if I am using the canvas surfaceview? Would I have to do it in the object class? Inside of my view class? Any help is highly appreciated. Thanks in advance.


You could do it inside your view class, you could have a Rect instance called boundingBox or somthing, then have a meathod called checkBounds(int x, int y) that returns a boolean, then inside the checkBounds meathod just do:

if(boundingBox.contains(x,y))
{
    //put code here that moves a character or somthing
}else{
    //put code here that says a character cannot move or somthing
}

so that way the meathod can be called from a bunch of different places.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜