Skip to content

Commit

Permalink
bump version to 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sscovil committed Jun 9, 2024
1 parent 9d812d9 commit e85fbdc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
47 changes: 43 additions & 4 deletions addons/split_screen_2d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ Finally, you'll need to configure the `SplitScreen2D` by assigning it a `Play Ar

## Configuration

Configure the `SplitScreen2D` node by selecting it in the scene tree and assigning the `Play Area`, `Min Players`, and
`Max Players` properties in the inspector.
Configure the `SplitScreen2D` node by selecting it in the scene tree and assigning the `Play Area`, `Min Players`,
`Max Players`, and `Transparent Background` properties in the inspector.

![Example Configuration](https://raw.githubusercontent.com/sscovil/godot-split-screen-2d-addon/main/screenshots/screenshot_05.png)

Expand All @@ -82,6 +82,8 @@ func _ready():
# Set the minimum and maximum number of players (default is 1 to 8).
split_screen_2d.min_players = 2
split_screen_2d.max_players = 4
# Give the viewports transparent backgrounds (default is `false`).
split_screen_2d.transparent_background = true
```

Likewise, you can add player nodes in code:
Expand All @@ -96,12 +98,49 @@ func _input():
if Input.is_action_just_pressed("ui_accept"):
# Assuming `Player` is a class you created for your players.
var player = Player.new()
# Code to configure player goes here.
# Add the player to the split screen.
split_screen_2d.add_player(player)
```

You can also programatically add a `SplitScreen2D` node to your scene tree, using the static `from_config()` method:

```gdscript
class_name Example
extends Node2D
## This will be added to the scene tree when we call `initialize_split_screen()`.
var split_screen_2d: SplitScreen2D
func _ready():
var config := SplitScreen2DConfig.new()
config.play_area = load_level(1)
config.max_players = 2
var split_screen = SplitScreen2D.from_config(config)
var players = [
load_player("Player 1"),
load_player("Player 2"),
]
for player in players:
split_screen.add_player(player)
add_child(split_screen)
func load_level(level_number: int) -> Level:
# Replace this example code with the code you use to load your game levels.
var level = load("res://path/to/level_%d.tscn" % level_number).instantiate()
return level
func load_player(player_name: String) -> Player:
# Replace this example code with the code you use to instantiate your players.
var player = load("res://path/to/player.tscn").instantiate()
player.set_player_name(player_name)
return player
```

The `SplitScreen2DConfig` class has all the same exported properties and default values as `SplitScreen2D`.

### Performance Optimization

The `SplitScreen2D` node will automatically rebuild its viewport tree whenever a player is added or removed, or when
Expand Down
2 changes: 1 addition & 1 deletion addons/split_screen_2d/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="SplitScreen2D"
description="Easily add a split-screen interface to your 2D game in Godot, with support for up to 8 players."
author="Shaun Scovil"
version="0.2.1"
version="0.3.0"
script="plugin.gd"

0 comments on commit e85fbdc

Please sign in to comment.