Created
April 26, 2015 20:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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