custom ScaleMode



  • Hello,

    I'm a brand new user of HaxeFlixel (usually I use OpenFL + Ash)!
    And I have a question about the best method to make a custom ScaleMode.

    My scale is particular because I need:

    • to scale proportionally some objects
    • to scale only on Y some other objects
    • to not scale other objects

    So is this possible to achieve that using a custom scale mode FlxG.scaleMode = scaleMode; and adding some flags on my objects?
    Or do I need to store all these objects in different array and scale by myself or does Flx objects have a scale mode option somewhere?

    Thanks.



  • From my understanding, ScaleMode is all about global scaling. If you want to scale per sprite, use

    sprite.scale.set(2, 2);
    sprite.updateHitbox();
    


  • Thanks!

    And should I listen to RESIZE EVENT of the app by myself or should I use BaseScaleMode.onMeasure() to compute the scale values I need for my objects?



  • You can get the new width and height when the game is resized using FlxG.signals.gameResized like this:

    FlxG.signals.gameResized.add(updateSize);
    
    function updateSize(width:Int, height:Int) {}
    


  • Great! Thanks!


Log in to reply