Skip to content

Instantly share code, notes, and snippets.

@KeyMaster-
Created April 26, 2015 20:21
Show Gist options
  • Save KeyMaster-/30a0509ee54c0ba15b84 to your computer and use it in GitHub Desktop.
Save KeyMaster-/30a0509ee54c0ba15b84 to your computer and use it in GitHub Desktop.
Example use of a screen-wide fluid to create global drag for nape bodies
var screenShape = new Polygon(Polygon.rect(0, 0, Luxe.screen.w, Luxe.screen.h, true));
screenShape.fluidEnabled = true;
//Density of 0.3, Viscosity of 3. These are values you just have to experiment with until it feels right
screenShape.fluidProperties = new FluidProperties(0.3, 3);
//It's important to set the collisionMask (second parameter) to 0 here,
//so the shape doesn't collide with anything (we want everything to just move through it)
screenShape.filter = new InteractionFilter(1, 0);
//Set up a body holding the shape and add it to the space
var screenBody = new Body(BodyType.STATIC);
screenBody.shapes.add(screenShape);
screenBody.space = Luxe.physics.nape.space;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment