public void die(DeathType death) { if(alive) { if (grabbed != null) { stopGrabbing(false); } gameWorld.startRespawnClock(this); Fixture f = body.getFixtureList().get(0); Filter fi = f.getFilterData(); fi.categoryBits = BodyFactory.CAT_DECEASED; fi.maskBits = BodyFactory.MASK_DECEASED; f.setFilterData(fi); body.getFixtureList().set(0, f); super.die(death); } }
public void swapWorldLayers(LayerHandler lh) { removeFromWorldLayers(lh); lh.addEntityToLayer(this, LayerHandler.ground); swapped = true; Fixture f = body.getFixtureList().get(0); Filter fi = f.getFilterData(); fi.categoryBits = BodyFactory.CAT_IMPASSABLE; fi.maskBits = BodyFactory.MASK_SHERIFF_GROUND; f.setFilterData(fi); body.getFixtureList().set(0, f); canFire = false; TimerManager.addTimer(swapTimer); }
@Override protected Body createBody(EntityDefinition definition) { BodyDef bodyDef = definition.getBodyDef(); bodyDef.position.set(definition.getCenter()); Body body = Level.getInstance().getPhysicsWorld().createBody(bodyDef); FixtureDef fixtureDef = createFixtureDef(); body.createFixture(fixtureDef); fixtureDef.shape.dispose(); body.setBullet(true); attachFootSensor(body, definition.getSize().x); Filter filter = new Filter(); filter.categoryBits = 0x0001; filter.maskBits = ~Player.COLLISION_MASK; body.getFixtureList().get(0).setFilterData(filter); return body; }
public WallActor(JumplingsWorld world, PointF worldPos, PointF p0, PointF p1, boolean floor, boolean security) { super(world, worldPos, p0, p1, false); Filter filter = (floor) ? FLOOR_FILTER : WALL_FILTER; for (int i = 0; i < mBodies.size(); i++) { Body b = mBodies.get(i); // b.setBullet(true); ArrayList<Fixture> fs = b.getFixtureList(); int l2 = fs.size(); for (int i2 = 0; i2 < l2; i2++) { Fixture f = fs.get(i2); f.setRestitution(WALL_RESTITUTION); f.setFilterData(filter); } } this.floor = floor; this.security = security; }
private void configEntity(Entity entity) { IdentityComponent identity = getComponent(entity, IdentityComponent.class, true); identity.uuid = IDS++; if (Settings.DEBUG_ENTITY != null) tag = String.format("%s::%s:", this.getClass().getSimpleName(), identity.tag); if (!tagEntities.containsKey(identity.tag)) { tagEntities.put(identity.tag, new Array<Entity>()); } tagEntities.get(identity.tag).add(entity); RigidBodiesComponents rigidBodies = getComponent(entity, RigidBodiesComponents.class, false); if (rigidBodies != null) { for (Body rigidBody : rigidBodies.rigidBodies) { rigidBody.setUserData(entity); for (Fixture fixture : rigidBody.getFixtureList()) { Filter filter = new Filter(); filter.categoryBits = identity.category; filter.maskBits = identity.collisionMask; filter.groupIndex = identity.group; fixture.setFilterData(filter); } } } }
/** * Set a category group to all fixtures of a single body. * * @param group * Id - Negative id does not collide with those with the same * group id Positive id collides with only those with the same * group id. Default is 0, which collides with everything; */ @Prop(name = "Collision Group") public void setCollisionGroup(int group) { // Create a filter Filter filter; // Set all fixtures of the body to the same Collision Group. Array<Fixture> fixtures = mBody.getFixtureList(); for (Fixture f : fixtures) { // Get the Current Filter data filter = f.getFilterData(); // Change the group index filter.groupIndex = (short) group; // Apply the new filter to the fixture. f.setFilterData(filter); } mCollisionGroup = group; }
/** * @param textReg * @param x * @param y * @param world */ public Bullet(TextureRegion textReg, float x, float y, World world) { super(textReg, x, y, world, "bullet"); mBody.setBullet(true); // More accurate collision detection for (Fixture fixture : mBody.getFixtureList()) { fixture.setDensity(0); fixture.setRestitution(1); fixture.setFriction(0); Filter filter = fixture.getFilterData(); filter.categoryBits = EEnityCategories.BULLET.getValue(); filter.maskBits &= ~EEnityCategories.BULLET.getValue(); fixture.setFilterData(filter); } mBody.setLinearDamping(0); mSpeed = SPEED; mDamage = 20f; }
/** * @param textReg * @param x * @param y * @param world */ public Enemy(TextureRegion textReg, float x, float y, World world) { super(textReg, x, y, world, "square"); setAI(AI.RandomFactory(this)); mBody.setBullet(true); // More accurate collision detection mBody.setFixedRotation(true); Fixture fixture = mBody.getFixtureList().get(0); fixture.setDensity(0.1f); fixture.setRestitution(1); fixture.setFriction(0); Filter filter = fixture.getFilterData(); filter.categoryBits = EEnityCategories.ENEMY.getValue(); filter.maskBits = (short) (EEnityCategories.ALL.getValue() & ~EEnityCategories.ENEMY .getValue()); fixture.setFilterData(filter); mSpeed = SPEED; mHealth = MAX_HEALTH; mDamage = 5f; }
/** * Creates and sets the collision filter mask and category of this object */ @Override public void createFilterMask() { Filter filter = new Filter(); filter.categoryBits = MainGameClass.CATEGORY_WEAPON; filter.maskBits = MainGameClass.MASK_WEAPON; fixture.setFilterData(filter); }
/** * Creates and sets the collision filter mask and category of this object */ @Override public void createFilterMask() { Filter filter = new Filter(); filter.categoryBits = MainGameClass.CATEGORY_ENEMY_MOVE_BORDER; filter.maskBits = MainGameClass.MASK_ENEMY_MOVE_BORDER; fixture.setFilterData(filter); }
/** * Creates and sets the collision filter mask and category of this object */ @Override public void createFilterMask() { Filter filter = new Filter(); filter.categoryBits = MainGameClass.CATEGORY_DEATHTILE; filter.maskBits = MainGameClass.MASK_DEATHTILE; fixture.setFilterData(filter); }
/** * Creates and sets the collision filter mask and category of this object */ @Override public void createFilterMask() { Filter filter = new Filter(); filter.categoryBits = MainGameClass.CATEGORY_FINISH; filter.maskBits = MainGameClass.MASK_FINISH; fixture.setFilterData(filter); }
/** * Creates and sets the collision filter mask and category of this object */ @Override public void createFilterMask() { Filter filter = new Filter(); filter.categoryBits = MainGameClass.CATEGORY_GROUND; filter.maskBits = MainGameClass.MASK_GROUND; fixture.setFilterData(filter); }
/** * Creates and sets the collision filter mask and category of this object */ @Override public void createFilterMask() { Filter filter = new Filter(); filter.categoryBits = MainGameClass.CATEGORY_JUMPABLE; filter.maskBits = MainGameClass.MASK_JUMPABLE; fixture.setFilterData(filter); }
public void die(DeathType death) { if(alive) { if (gameWorld instanceof BossFight) { ((BossFight)gameWorld).startRespawnClock(this); } else { gameWorld.startRespawnClock(this); } if(death == DeathType.CAPTURE) { shouldMakeCorpse = false; CGCWorld.addToDestroyList(this); if (Options.storedTrackingOption) { ChaseApp.stats.getStatByIndex(getCurrentMapIndex()).captures++; } } else { Fixture f = body.getFixtureList().get(0); Filter fi = f.getFilterData(); fi.categoryBits = BodyFactory.CAT_DECEASED; fi.maskBits = BodyFactory.MASK_DECEASED; f.setFilterData(fi); body.getFixtureList().set(0, f); } fixKeyIDs(playerID); super.die(death); alive = false; } rightJoint = null; }
public void die() { removeFromWorldLayers(CGCWorld.getLH()); swapped = true; Fixture f = body.getFixtureList().get(0); Filter fi = f.getFilterData(); fi.categoryBits = BodyFactory.CAT_NON_INTERACTIVE; fi.maskBits = BodyFactory.MASK_NON_INTERACTIVE; f.setFilterData(fi); body.getFixtureList().set(0, f); body.setUserData(this); if (leftShooter != null) { if (rightShooter != null) { rightShooter.dismount(); } leftShooter.dismount(); sheriff.addTargeter(); } sheriff.swapWorldLayers(CGCWorld.getLH()); sheriff.getBody().setUserData(sheriff); TimerManager.removeTimer(dieClock); }
boolean contactFilter(Fixture fixtureB) { Filter filterB = fixtureB.getFilterData(); if (filterA.groupIndex != 0 && filterA.groupIndex == filterB.groupIndex) return filterA.groupIndex > 0; return (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0; }
/** * Creates new contact filter for this light with given parameters * * @param categoryBits - see {@link Filter#categoryBits} * @param groupIndex - see {@link Filter#groupIndex} * @param maskBits - see {@link Filter#maskBits} */ public void setContactFilter(short categoryBits, short groupIndex, short maskBits) { filterA = new Filter(); filterA.categoryBits = categoryBits; filterA.groupIndex = groupIndex; filterA.maskBits = maskBits; }
boolean globalContactFilter(Fixture fixtureB) { Filter filterB = fixtureB.getFilterData(); if (globalFilterA.groupIndex != 0 && globalFilterA.groupIndex == filterB.groupIndex) return globalFilterA.groupIndex > 0; return (globalFilterA.maskBits & filterB.categoryBits) != 0 && (globalFilterA.categoryBits & filterB.maskBits) != 0; }
/** * Creates new contact filter for ALL LIGHTS with give parameters * * @param categoryBits - see {@link Filter#categoryBits} * @param groupIndex - see {@link Filter#groupIndex} * @param maskBits - see {@link Filter#maskBits} */ static public void setGlobalContactFilter(short categoryBits, short groupIndex, short maskBits) { globalFilterA = new Filter(); globalFilterA.categoryBits = categoryBits; globalFilterA.groupIndex = groupIndex; globalFilterA.maskBits = maskBits; }
/** * create new contact filter for ALL LIGHTS with give parameters * * @param categoryBits * @param groupIndex * @param maskBits */ static public void setContactFilter(short categoryBits, short groupIndex, short maskBits) { filterA = new Filter(); filterA.categoryBits = categoryBits; filterA.groupIndex = groupIndex; filterA.maskBits = maskBits; }
@Override public void load(OverlapScene scene, Entity entity, ObjectMap<String, String> value) { PhysicsComponent physics = Mappers.physics.get(entity); Filter filter = new Filter(); filter.categoryBits = physicsSystem.getCategories().getBits("box"); for(Fixture fixture : physics.body.getFixtureList()) { fixture.setFilterData(filter); } }
/** * Switch player mask bits to next block. */ private void switchBlocks() { // get player foot mask bits Filter filter = player.getBody().getFixtureList().get(1).getFilterData(); short bits = filter.maskBits; // switch to next block bit // red -> green -> blue if (bits == B2DVars.BIT_RED_BLOCK) { bits = B2DVars.BIT_GREEN_BLOCK; } else if (bits == B2DVars.BIT_GREEN_BLOCK) { bits = B2DVars.BIT_BLUE_BLOCK; } else if (bits == B2DVars.BIT_BLUE_BLOCK) { bits = B2DVars.BIT_RED_BLOCK; } // set player foot mask bits filter.maskBits = bits; player.getBody().getFixtureList().get(1).setFilterData(filter); // set player mask bits bits |= B2DVars.BIT_CRYSTAL | B2DVars.BIT_SPIKE; filter.maskBits = bits; player.getBody().getFixtureList().get(0).setFilterData(filter); // play sound Game.res.getSound("changeblock").play(); }
public static FixtureDef createFixtureDef(final float pDensity, final float pElasticity, final float pFriction, final boolean pSensor, final short pCategoryBits, final short pMaskBits, final short pGroupIndex) { final FixtureDef fixtureDef = new FixtureDef(); fixtureDef.density = pDensity; fixtureDef.restitution = pElasticity; fixtureDef.friction = pFriction; fixtureDef.isSensor = pSensor; final Filter filter = fixtureDef.filter; filter.categoryBits = pCategoryBits; filter.maskBits = pMaskBits; filter.groupIndex = pGroupIndex; return fixtureDef; }
public void kill() { currentState = State.DEAD; Filter filter = new Filter(); filter.maskBits = MarioBros.NOTHING_BIT; for (Fixture fixture : b2body.getFixtureList()) { fixture.setFilterData(filter); } b2body.applyLinearImpulse(new Vector2(0, 5f), b2body.getWorldCenter(), true); }
private void kill() { MarioBros.manager.get("audio/music/mario_music.ogg", Music.class).stop(); MarioBros.manager.get("audio/sounds/mariodie.wav", Sound.class).play(); marioIsDead = true; Filter filter = new Filter(); filter.maskBits = MarioBros.NOTHING_BIT; for (Fixture fixture : b2body.getFixtureList()) { fixture.setFilterData(filter); } b2body.applyLinearImpulse(new Vector2(0, 3), b2body.getWorldCenter(), true); }
public void fromFixture(Fixture f){ shapeModel = new ShapeModel(f.getShape()); Filter filterData = f.getFilterData(); filter.categoryBits = filterData.categoryBits; filter.maskBits = filterData.maskBits; filter.groupIndex = filterData.groupIndex; sensor = f.isSensor(); density = f.getDensity(); friction = f.getFriction(); restitution = f.getRestitution(); }
public void fromFixtureDef(FixtureDef fd){ shapeModel = new ShapeModel(fd.shape); Filter filterData = fd.filter; filter.categoryBits = filterData.categoryBits; filter.maskBits = filterData.maskBits; filter.groupIndex = filterData.groupIndex; sensor = fd.isSensor; density = fd.density; friction = fd.friction; restitution = fd.restitution; }
public void setFilter(short category, short mask){ for (Fixture f : scene.getFixtures()){ Filter filter = f.getFilterData(); filter.categoryBits = category; filter.maskBits = mask; f.setFilterData(filter); } }
/** * create new contact filter for light with give parameters * * @param categoryBits * @param groupIndex * @param maskBits */ public void setContactFilter(short categoryBits, short groupIndex, short maskBits) { filterA = new Filter(); filterA.categoryBits = categoryBits; filterA.groupIndex = groupIndex; filterA.maskBits = maskBits; }
@Override public void initialize(World box2dworld) { // Create our body definition BodyDef bodyDef = new BodyDef(); // Set its world position bodyDef.position.set(new Vector2(0, 10)); bodyDef.type = BodyType.StaticBody; // Create a body from the defintion and add it to the world body = box2dworld.createBody(bodyDef); // Create a polygon shape PolygonShape groundBox = new PolygonShape(); // Set the polygon shape as a box which is twice the size of our view port and 20 high // (setAsBox takes half-width and half-height as arguments) groundBox.setAsBox(width/2, length/2); // Create a fixture from our polygon shape and add it to our ground body Fixture fixture = body.createFixture(groundBox, 0.0f); Filter filter = new Filter(); filter.categoryBits = C.CATEGORY_SCENERY; filter.maskBits = (short) -1; fixture.setFilterData(filter); // Clean up after ourselves groundBox.dispose(); }
@Override public void initialize(World box2dworld) { // Create our body definition BodyDef groundBodyDef =new BodyDef(); // Set its world position groundBodyDef.position.set(new Vector2(50, 100)); groundBodyDef.type = BodyType.DynamicBody; groundBodyDef.fixedRotation = true; // Create a body from the defintion and add it to the world body = box2dworld.createBody(groundBodyDef); body.setLinearDamping(10f); // Create a polygon shape PolygonShape groundBox = new PolygonShape(); // Set the polygon shape as a box which is twice the size of our view port and 20 high // (setAsBox takes half-width and half-height as arguments) groundBox.setAsBox(0.8f, 1.4f); // Create a fixture from our polygon shape and add it to our ground body Fixture fixture = body.createFixture(groundBox, 1.0f); Filter filter = new Filter(); filter.categoryBits = C.CATEGORY_ACTOR; filter.maskBits = (short) -1; fixture.setFilterData(filter); // Clean up after ourselves groundBox.dispose(); }
@Override public void initialize(World box2dworld) { // Create our body definition BodyDef bodyDef =new BodyDef(); // Set its world position bodyDef.position.set(new Vector2(0, 10)); bodyDef.type = BodyType.DynamicBody; bodyDef.bullet = true; // Create a body from the defintion and add it to the world body = box2dworld.createBody(bodyDef); // Create a polygon shape PolygonShape groundBox = new PolygonShape(); // Set the polygon shape as a box which is twice the size of our view port and 20 high // (setAsBox takes half-width and half-height as arguments) groundBox.setAsBox(width/2, length/2); // Create a fixture from our polygon shape and add it to our ground body Fixture fixture = body.createFixture(groundBox, 0.1f); Filter filter = new Filter(); filter.categoryBits = C.CATEGORY_ITEM; filter.maskBits = (short) ~C.CATEGORY_ITEM; fixture.setFilterData(filter); // Clean up after ourselves groundBox.dispose(); }
/** * @param textReg * @param x * @param y * @param world */ public Portal(TextureRegion textReg, float x, float y, World world) { super(textReg, x, y, world, "circle"); Fixture fixture = mBody.getFixtureList().get(0); Filter filter = fixture.getFilterData(); filter.categoryBits = EEnityCategories.BOUNDARY.getValue(); filter.maskBits = EEnityCategories.PLAYER.getValue(); fixture.setFilterData(filter); mBody.setType(BodyType.StaticBody); }
public Player(TextureRegion reg, TiledMap map, MapActions actions, int x, int y, World world) { super(reg, x, y, world, "circle"); Gdx.app.log(TAG, String.format("Player spawned at (%d, %d)", x, y)); mBody.setFixedRotation(true); Fixture fixture = mBody.getFixtureList().get(0); Filter filter = fixture.getFilterData(); filter.categoryBits = EEnityCategories.PLAYER.getValue(); fixture.setFilterData(filter); mActions = actions; mSpeed = SPEED; mHealth = MAX_HEALTH; }