Skip to content

Commit

Permalink
don't reset actors each frame by default; make the behavior toggleable
Browse files Browse the repository at this point in the history
  • Loading branch information
oatmealine committed Dec 9, 2022
1 parent 5e3713d commit 5388b2c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
21 changes: 16 additions & 5 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ text:rotationz(30)
text:diffuse(1, 0.8, 0.8, 1)
```

All methods that you run upon definition will be ran again at the start of every frame:
All methods that you run upon definition will be ran again at the start of every frame with `resetOnFrameStart`:

```lua
resetOnFrameStart(true)

local quad = Quad()
quad:xy(scx, scy)
quad:zoomto(60, 60)
Expand All @@ -217,7 +219,7 @@ function uranium.update()
end
```

If you want to avoid this, or otherwise call getter methods, use the [`uranium.init`](#uraniuminit) callback:
If you want to avoid this for individual actors, or otherwise call getter methods, use the [`uranium.init`](#uraniuminit) callback:

```lua
local sprite = Sprite()
Expand All @@ -235,6 +237,14 @@ sprite:addcommand('Init', function(self)
end)
```

Or, you can disable the frame resetting functionality individually:
```lua
resetOnFrameStart(true)
local sprite = Sprite()
resetActorOnFrameStart(sprite, false)
sprite:Draw() -- will not be called per-frame
```

### Accessing raw actors

As you may have noticed, when you print an actor defined with Uranium, it won't show up as an actor - it'll show up as a "proxy" of an actor. This is because we can't actually get actors created on demand in NotITG - what happens instead is you get an object that _acts_ like an actor by calling all the same methods you pass into it, but isn't really one.
Expand Down Expand Up @@ -1134,6 +1144,7 @@ quad:xy(scx, scy)
quad:zoom(120)
quad:diffuse(0.8, 1, 0.7, 1)
quad:skewx(0.2)
resetActorOnFrameStart(quad)

-- define a sprite
local sprite = Sprite('docs/uranium.png')
Expand Down Expand Up @@ -1363,12 +1374,12 @@ void main() {
gl_FragColor = col * color;
}
]])
shader:uniform1f('yo', 1)
shader:uniform1f('scale', 0.25)

setShader(sprite, shader)

function uranium.update()
shader:uniform1f('yo', 1)
shader:uniform1f('scale', 0.25)

shader:uniform1f('tx', t)
shader:uniform1f('ty', t)

Expand Down
1 change: 1 addition & 0 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ quad:xy(scx, scy)
quad:zoom(120)
quad:diffuse(0.8, 1, 0.7, 1)
quad:skewx(0.2)
resetActorOnFrameStart(quad)

-- define a sprite
local sprite = Sprite('docs/uranium.png')
Expand Down
2 changes: 1 addition & 1 deletion template
Submodule template updated from f4e8c1 to 0a1805

0 comments on commit 5388b2c

Please sign in to comment.