Skip to content

Commit ad4e900

Browse files
committed
custom claszes
1 parent 62f9852 commit ad4e900

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
# Custom Classes
22

3-
well it seems like i have no idea how these work myself
3+
Custom classes can be made either inside the script you need it in or you can make a script file coresponding with the name of the class in ``./source``, and using `import` to import it.
4+
5+
Here is a basic Song Script code that uses it:
6+
```hx
7+
class SpecialSprite extends FlxSprite {
8+
public var customValue:String = null;
9+
public function new(x:Float, y:Float, customValue:String) {
10+
super(x, y);
11+
this.customValue = customValue;
12+
//other code stuff
13+
}
14+
15+
public override function update(elapsed) {
16+
super.update(elapsed);
17+
}
18+
}
19+
20+
function create() {
21+
var spr = new SpecialSprite(200, 400, "powerful");
22+
add(spr);
23+
}
24+
```
25+
26+
### Particularities
27+
As of writing this, this system is very limited and also presents some defects. For example:
28+
- You cannot extend FlxGroups or other typed classes *(the ones that end with a ``<T>``)*.
29+
- Certain classes like FlxText needs to have their ``update`` function manually called.
30+
- all variables need to be public in order to be accessed inside the class.

0 commit comments

Comments
 (0)