-
I was curious what it was because with a different hscript class I use they had a parenting system. // soure class
class CoolSprite extends FlxSprite {
public var cheese:Int = 0;
public var script:Script = new Script(this);
// pretend there are script calls for func create and shit lol
}
// script contents
function create():Void {
trace(cheese); // 0
cheese++;
trace(cheese); // 1
} |
Beta Was this translation helpful? Give feedback.
Answered by
Kriptel
Dec 5, 2024
Replies: 1 comment 1 reply
-
By setting source var object:FlxSprite = new FlxSprite(100,0);
var script:RuleScript = new RuleScript();
script.superInstance = object;
// ... script execute script trace(x); // 100, because sprite's x value is 100
x = 200;
trace(x) // 200, It will also change for the object |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rodney528
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By setting
superInstance
to a non-null value, you are telling scripts that it should change variables in the parent class, if any exist.source
script