I don't understand at all? Is it bit-wise and shit, I'm not too keen on that. Same for setCategory, setCategoryBits and setMaskBits.
Can somebody please explain to me setMask?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Can somebody please explain to me setMask?
Code: Select all
shape1:setCategory(1)
shape2:setCategory(2)
shape3:setMask(1) -- Does not collide with shape1
shape4:setMask(1, 2) -- Does not collide with shape1 nor shape2 (does collide with shape3)
Re: Can somebody please explain to me setMask?
What is mask bits and category bits?
Re: Can somebody please explain to me setMask?
The box2d documentation will have a very good explanation of this (if i remember correctly), check it out
Re: Can somebody please explain to me setMask?
It doesn't, that's why I'm asking here.
Re: Can somebody please explain to me setMask?
I think the explanation is that a category can be a number between 0 and 15 (i.e. 16 categories).
So when you want to specify a list of categories, you can either list them:
Or you can use a single number to represent this list. To do that, you calculate the sum of 2^category and use the result.
In this case: bits = 2^1+2^3+2^10 = 2+8+1024 = 1034. Then you use the "bits" function:
Why "bits"? Because when you look at 1034 as bits (in binary notation), you get 0000010000001010. You have '1' for the categories the shape belongs to, and '0' for the categories it doesn't belong to. And the same can be used for the mask (i.e. categories the shape can collide with).
So the short answer is, yes, it's bit-wise and shit...
So when you want to specify a list of categories, you can either list them:
Code: Select all
shape:setCategory(1,3,10)
In this case: bits = 2^1+2^3+2^10 = 2+8+1024 = 1034. Then you use the "bits" function:
Code: Select all
shape:setCategoryBits(1034)
So the short answer is, yes, it's bit-wise and shit...
Re: Can somebody please explain to me setMask?
Hmm, I think I understand a bit better, thanks.
- athanazio
- Citizen
- Posts: 96
- Joined: Fri Apr 10, 2009 3:12 am
- Location: Rio de Janeiro - Brazil
- Contact:
Re: Can somebody please explain to me setMask?
rude,
I believe the comment you did
I believe the comment you did
is very clear and should go to the documentation !!shape1:setCategory(1)
shape2:setCategory(2)
shape3:setMask(1) -- Does not collide with shape1
shape4:setMask(1, 2) -- Does not collide with shape1 nor shape2 (does collide with shape3)
Nothing is simple but everything is possible.
Re: Can somebody please explain to me setMask?
Then please add it to the issue tracker, or I'll forget it! I'm not going to update the docs until the new documentation system [1] is in place (unless there are errors).athanazio wrote:... is very clear and should go to the documentation !!
[1]: Yes, YET another one.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 7 guests