Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.82k stars 821 forks source link

Can I get Starling.contentScaleFactorX and Starling.contentScaleFactorY? #988

Closed daicemirror closed 6 years ago

daicemirror commented 6 years ago

In fact, this is to solve the following issue of Feathers . https://github.com/BowlerHatLLC/feathers/issues/1596 I can fix the feathers issue by extending the Feathers TextRender components with contentScaleFactorX and contentScaleFactorY that I calculated myself. And I also realize Starling does not seem to support this behavior, too. Please give me some advice about this issue. Will these two Attributes be added? Thanks!

PrimaryFeather commented 6 years ago

Actually, the contentScaleFactor is very easy to calculate. As you can see here, it's actually just viewPort.width / stage.stageWidth. (The backbufferScaleFactor is only used for Desktop Retina screens; it's normally just '1'.)

So you could simply calculate the value for contentScaleFactorY by using the height and stageHeight values, respectively.

However, the problem is that Starling expects the values to be the same (i.e. the stage not being stretched) in several places. The TextField is one of them, another are RenderTextures. So you might still see some artifacts, depending on the components you are using. I recommend you just try it out!