Bottom right alignment

Hi all

I am aligning some text bottom right of my screen. This obviously isn’t a problem until I start thinking about more than one device.

I am using dynamic scaling and in particular ZoomEven as opposed to LetterBox as it just works better for me.

What is the best way for a consistent and best practice way without having a load of conditional offsets based on different devices and platforms.

Your help as always is appreciated

J (A Parachuting Frog) [import]uid: 103970 topic_id: 21746 reply_id: 321746[/import]

I would think that zoomEven would work fairly well in this regard although not having played with it across enough devices (I normally use letterbox) I might be mistaken.

Are you encountering issues using zoomEven with positioning?

Peach :slight_smile: [import]uid: 52491 topic_id: 21746 reply_id: 86431[/import]

Hi Peach

Yes I’m struggling with the way dynamic scaling works with the screen bleed. Normally doing [lua]display.contentHeight[/lua] or [lua]display.contentWidth[/lua] gives you the original size and not the actual device screen size.

As a result anything bottom right can be partially visible or not even there if the scaling isn’t proportional from the original size. You can get round this along the top dependent on your reference point but can’t stick all at top otherwise look crowded.

It must be a common problem so was interested how people combated it

J [import]uid: 103970 topic_id: 21746 reply_id: 86436[/import]

If this is an iOS app then checking whether the device is an iPad or not then making adjustments based on the device is one way I’ve heard of people tackling it. [import]uid: 52491 topic_id: 21746 reply_id: 86438[/import]

It’s both android and iOS. I don’t want to be going conditionals per platform and won’t really scale to android where there are do many different devices.

There is a visible width method or equivalent? [import]uid: 103970 topic_id: 21746 reply_id: 86447[/import]

Possibly using the “magic recipe” from here; http://blog.anscamobile.com/2010/11/content-scaling-made-easy/ could be worth a go in that case.

Some discussion about the new content scale APIs was mentioned in another thread related to this too, although I haven’t looked into that yet.

Peach :slight_smile: [import]uid: 52491 topic_id: 21746 reply_id: 86548[/import]

I’m having the same issue. I looked at the “magic recipe” but want to use zoomEven instead of letterbox. All my background images have enough bleed to handle the various aspect ratios. I just need to know what the viewable width and height is for aligning objects to the edges of the screen. [import]uid: 126865 topic_id: 21746 reply_id: 88155[/import]

And to elaborate, I would be willing to use letterbox if the “black bar” areas were ignored instead of capturing touch events. [import]uid: 126865 topic_id: 21746 reply_id: 88156[/import]

Ok, I answered my own question while being able to use the zoomEven scaling.

I added the following at the top of my module

local \_originX = display.screenOriginX local \_originY = display.screenOriginY local \_W = display.contentWidth - (\_originX \* 2) local \_H = display.contentHeight - (\_originY \* 2)

and to center text on the bottom of the screen I did this:

display.newText( message, \_W / 2 + \_originX, \_H - 30 + \_originY, native.systemFont, 24)

I’m not sure if this is the “proper” way to do this but it works for me. I haven’t played around with the physics stuff yet so I’m not sure if objects will bounce of the visible boundaries or the backgrounds boundaries yet. [import]uid: 126865 topic_id: 21746 reply_id: 88168[/import]

@andybarilla excellent solution seems to work on all the simulator devices

Note if you want to align at the top don’t use zero but _originY. A little gotcha which you explained but I missed when implementing [import]uid: 103970 topic_id: 21746 reply_id: 88176[/import]

Glad to see this got resolved in a less than an hour - and you even provided a follow up!

Great stuff :slight_smile: [import]uid: 52491 topic_id: 21746 reply_id: 88272[/import]

Anyone found that this approach with the recent daily build isn’t working.

For me now this isn’t aligning bottom right when it used to across all devices [import]uid: 103970 topic_id: 21746 reply_id: 91133[/import]