Hi. I’m using the physics engine in a Creator (v2.x) game currently, and the PhysicsBoxCollider component doesn’t seem to want to change its size when in the code. It seems to be stuck on a default square shape instead of changing when I use the code
newNode.getComponent(cc.PhysicsBoxCollider).size = new cc.v2(20, 200);
(and a bunch of variations of that statement, such as using the cc.size method, ._size as the property name, the keyword new
, etc.). I’ve also tried messing around with the preview settings, but so far have had no success. Any help would be appreciated.
try this.
var collider = newNode.getComponent(cc.PhysicsBoxCollider);
collider.size = new cc.size(20, 200);
collider.apply();
Yep that definitely works! Thank you for the help .