Skip to content

Commit

Permalink
update for 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cadin committed Oct 13, 2023
1 parent 67d4cef commit 3750a99
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
43 changes: 41 additions & 2 deletions docs/comic-data/custom-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,33 @@ local function renderPanel6B(panel, offset)
end
```

### Drawing Layers
### Render Individual Layers

Setting a render function for a panel ejects it from the framework's normal rendering flow. This means your function becomes responsible for _all_ the logic and drawing in your panel.

Normally this would mean you need to calculate parallax and layer positions manually before drawing images to the screen (see below).

You can bypass those requirements by using the `Panels.renderLayerInPanel()` function. This allows you to intercept panel rendering with a custom function, alter layer data or toggle layers based on [global variables]({{site.baseurl}}/docs/comic-data/variables), then hand them over to Panels to render for you.

The function accepts the layer data, the panel data, and the scroll offset.

Example:
{: .text-delta}

```lua
local function renderPanel6B(panel, offset)
for i, layer in ipairs(panel.layers) do
if layer.name ~= 'hiddenLayer' then
Panels.renderLayerInPanel(layer, panel, offset)
end
end
end
```

### Drawing Layers Manually

If you choose not to use `Panels.renderLayerInPanel()`, then you'll need to draw everything in your panel manually.

You can access your panel's layers with the `panel.layers` property. Loop through them to draw the contents of your panel. An image layer will have the `playdate.graphics.image` stored in its `img` property.

Example:
Expand All @@ -54,7 +77,7 @@ end

### Calculating Parallax

Since your panel has been taken out of the render flow, you'll need to calculate layer position yourself if you want parallax scrolling.
Since your panel has been taken out of the render flow, if you're not using `Panels.renderLayerInPanel()` you'll need to calculate layer position yourself if you want parallax scrolling.

The example below shows how you might calculate x position for layers in a horizontally-scrolling sequence. A vertical sequence would be the same, substituting `y` for `x` and `height` for `width`.

Expand Down Expand Up @@ -148,4 +171,20 @@ local function targetSequenceForS02()
return 5
end
end
```

## Update

Assign a custom function to a panel's [`updateFunction`]({{site.baseurl}}/docs/comic-data/panels#updatefunction) property.
This function will be called every frame while your panel is on screen.

Update functions allow you to intercept user input or perform other custom logic without having to take over rendering the panel as you would with a custom render function.

Example:
{: .text-delta}

```lua
local function updatePanel6B(panel, offset)
-- handle input or perform other custom logic
end
```
9 changes: 9 additions & 0 deletions docs/comic-data/panels.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,13 @@ FOR NONLINEAR COMICS ONLY

In a comic with a [branching storyline](({{site.baseurl/docs/nonlinear-comics.html}})), this function defines the next sequence to present by returning the target sequence number. This function is called when the panel scrolls off screen (before resetting the panel).

For more information see [Custom Functions]({{site.baseurl}}/docs/comic-data/custom-functions).

### updateFunction

default: nil
{: .prop-default}

A custom update function for this panel. This function gets called for every frame update. It runs independently from rendering, so you can perform custom logic here while still letting Panels handle panel rendering

For more information see [Custom Functions]({{site.baseurl}}/docs/comic-data/custom-functions).
11 changes: 11 additions & 0 deletions docs/comic-data/sequences.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,14 @@ OPTIONS:

- `Panels.Color.WHITE`
- `Panels.Color.BLACK`


### endSequence

default: false
{: .prop-default}

FOR NONLINEAR COMICS ONLY
{: .text-yellow-300 .fs-2 .lh-0}

Specify that a sequence is a dead end branch in your nonlinear comic. When a user advances past this sequence they will return to the main menu even if there are subsequent sequences listed in the comic data.
18 changes: 18 additions & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ With this set, you can omit the folder name when specifying audio in your comic

If you wish to specify files using the full path, set this property to `""`.

## Behavior Settings

### resetVarsOnGameOver

default: true
{: .prop-default }

If you're using [global variables]({{site.baseurl}}/docs/comic-data/variables) to track state in your comic, they will automatically reset when the user completes the game by finishing all sequences, or by hitting a sequence marked with the `endSequence` flag.

Set this to `false` to have Panels retain global vars between playthroughs. Variables will still be reset when the user chooses "Start Over" from the main menu.

### maxScrollSpeed

default: 8
{: .prop-default }

Change the maximum speed when scrolling with the d-pad. This does not affect crank scroll speed.

## Panel Settings

### defaultFrame
Expand Down

0 comments on commit 3750a99

Please sign in to comment.