Skip to content

Commit

Permalink
Update Scripting.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Dec 3, 2024
1 parent 5454dc9 commit bd58806
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/Scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,39 @@ var otherScript = importScript('assets.helpers.spriteHandler');
function create() {
otherScript.createSprite(0, 0, 'sprite');
}
```

### Using a Custom Shader
```hx
import('flixel.addons.display.FlxRuntimeShader');
import('openfl.filters.ShaderFilter');
import('openfl.utils.Assets');
import('flixel.FlxG');
import('backend.Paths');
var shader:FlxRuntimeShader;
var shader2:FlxRunTimeShader;
function create() {
shader = new FlxRuntimeShader(Assets.getText(Paths.frag('rain')), null);
shader.setFloat('uTime', 0);
shader.setFloatArray('uScreenResolution', [FlxG.width, FlxG.height]);
shader.setFloat('uScale', FlxG.height / 200);
shader.setFloat("uIntensity", 0.5);
shader2 = new ShaderFilter(shader);
FlxG.camera.filters = [shader2];
}
function update(elapsed:Float) {
shader.setFloat("uTime", shader.getFloat("uTime") + elapsed);
shader.setFloatArray("uCameraBounds", [
FlxG.camera.scroll.x + FlxG.camera.viewMarginX,
FlxG.camera.scroll.y + FlxG.camera.viewMarginY,
FlxG.camera.scroll.x + FlxG.camera.width,
FlxG.camera.scroll.y + FlxG.camera.height
]);
}
```
## Need Help?
If you need any general help or something goes wrong with your script, report an issue [here](https://github.com/Joalor64GH/Rhythmo-SC/issues).

0 comments on commit bd58806

Please sign in to comment.