Haxe Casting issue in C++

ShaunHaxe0 Comments

Haxe C++ target

When setting my top and bottom bounds for my game, I thought that cast would have done the job when I wanted to convert Float to Int. In flash this is fine, but I found in the C++ target it crashed the game.

My original code was this:

var top:Int = cast(this.bounds.top, Int);

By adjusting it to use the standard library, I fixed the issue by using int:

var top:Int = Std.int(this.bounds.top);

Leave a Reply

Your email address will not be published. Required fields are marked *