Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevebarnegren/sbdynamicwaternode
Physical water simulation for SpriteKit
https://github.com/stevebarnegren/sbdynamicwaternode
Last synced: 30 days ago
JSON representation
Physical water simulation for SpriteKit
- Host: GitHub
- URL: https://github.com/stevebarnegren/sbdynamicwaternode
- Owner: SteveBarnegren
- License: mit
- Created: 2016-03-09T17:33:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-04-22T20:29:18.000Z (over 8 years ago)
- Last Synced: 2024-09-17T06:06:24.019Z (about 2 months ago)
- Language: Objective-C
- Size: 1.63 MB
- Stars: 32
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DynamicWaterNode
[![Pod Version](http://img.shields.io/cocoapods/v/SBDynamicWaterNode.svg?style=flat)](http://cocoadocs.org/docsets/SBDynamicWaterNode/)
[![Pod Platform](http://img.shields.io/cocoapods/p/SBDynamicWaterNode.svg?style=flat)](http://cocoadocs.org/docsets/SBDynamicWaterNode/)
[![Pod License](http://img.shields.io/cocoapods/l/SBDynamicWaterNode.svg?style=flat)](http://cocoadocs.org/docsets/SBDynamicWaterNode/)2D physical water simulation for SpriteKit
![GIF](https://github.com/SteveBarnegren/DynamicWaterNode/raw/master/DynamicWater.gif)
# How to use
Add DynamicWaterNode.h, DynamicWaterNode.m, Droplet.png and Droplets.fsh to your project
Add to your scene:
```
- (void)didMoveToView:(SKView *)view {
self.waterNode = [[DynamicWaterNode alloc]initWithWidth:self.size.width
numJoints:100
surfaceHeight:kSurfaceHeight
fillColour:[UIColor colorWithRed:0 green:0 blue:1 alpha:0.5]];
self.waterNode.position = CGPointMake(self.size.width/2, 0);
[self addChild:self.waterNode];}
```Step the simulation in your scene’s update method. See demo project for an example of a fixed time step implementation
```
[self.waterNode update:dt];
```Call render: after the simulation has been updated. Only call render once each frame.
```
[self.waterNode render];
```Making splashes:
```
[self.waterNode splashAtX:100 force:20 width:20];
```Various properties of DynamicWaterNode can be changed to control the feel of the water. The demo project includes a settings screen where you can alter these to see their effect.