Skip to content

Commit

Permalink
Update 01 - scripting.md
Browse files Browse the repository at this point in the history
i actually had to test this first, so good news:
it works :D
  • Loading branch information
Joalor64GH authored Nov 8, 2024
1 parent def7709 commit a3ac7ee
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/01 - scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,33 @@ function new(/* arguments, if any */) {
}
```

### Using Imported Scripts
Script 1:
```hx
import('flixel.FlxSprite');
import('backend.Paths');
import('flixel.FlxG');
var state = FlxG.state;
function createSprite(x:Float, y:Float, graphic:String) {
var spr:FlxSprite = new FlxSprite(x, y);
spr.loadGraphic(Paths.image(graphic));
state.add(spr);
trace("sprite " + sprite + " created");
}
```

Script 2:
```hx
var otherScript = importScript('assets.helpers.spriteHandler');
function create() {
otherScript.createSprite(0, 0, 'sprite');
}
```

Also, if you want to load your custom state from the main menu, navigate to `assets/menuList.txt` and add in your state's name, as well as a main menu asset for it in `assets/images/menu/mainmenu/[name].png`.

As long as you've done everything correctly, your script should functioning. Otherwise, report an issue.

0 comments on commit a3ac7ee

Please sign in to comment.