You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The += operator does not update the value when used in class fields. However, direct assignment such as this.pos.x = this.pos.x + 1 works correctly.
Code exemple:
class Test {
private var pos:Vector2;
public function new(x, y:Single) {
this.pos = new Vector2(x, y);
}
public function update():Void {
this.pos.x += 1; // Doesn't work
this.pos.x = this.pos.x + 1; // Work
}
}
The text was updated successfully, but these errors were encountered:
voidTest_obj::update(){
cpp::Struct< Vector2 > fh = this->pos; // it's a copy, if only it was a reference -- cpp::Struct< Vector2 >& fh, it would work
fh->x = (fh->x + 1);
this->pos->x = (this->pos->x + 1);
}
All that remains is to find a way to make the transpiler generate it right.
This is one of those undocumented pitfalls when using cpp.Struct and similar, there's no real way around it. I do have new extern techniques on the way which aims to provide the same functionality and address theses sorts of issues.
The += operator does not update the value when used in class fields. However, direct assignment such as this.pos.x = this.pos.x + 1 works correctly.
Code exemple:
The text was updated successfully, but these errors were encountered: