[Resolved] Centering UI buttons not working on physical device

Hello everyone,

Forgive me for the long post as I am a new user and have been trying to figure out this problem for days! Here’s what I’m trying to accomplish so far. Right now I have everything in place that should load a splash screen, transition to a main menu after 5 seconds and the main menu has four UI buttons in it. Right now the first button just transitions to the gamemode.lua screen which currently just has a background. The other three buttons just print that they were clicked.

Here’s where the weirdness happens … The four buttons show up and function great in the simulator (Both iPhone and Android) but when I push the .apk to my physical Android devices (G2, Galaxy S3, Xoom), the four buttons on the main menu are ALWAYS stuck at 0,0 - their reference points are still defaulted to center (You can see the bottom-right quarter of one of the buttons and it doesn’t do anything when you click it).

All of my image paths, sound paths etc. are correct and exist etc.

I have tried everything I can think of to get the buttons to show up right … Does anyone see anything wrong or anything I can improve? Your help is greatly appreciated!

UPDATE: I shortened the post as I have found the issue to keep everyone from having to read a ton of unnecessary code. The issue was a capital B in the image file name!

Here is the code that was causing the issue:

[code]

– Create buttons
newGameButton = ui.newButton{
default = “images/redbutton.png”,
over = “images/redButtonover.png”,
onRelease = newGameButtonReleased,
id = “newGameButton”,
text = “New Game”,
font = “Astron Boy”,
textColor = { 51, 51, 51, 255 },
size = 22,
emboss = true
}
screenGroup:insert( newGameButton );

[/code] [import]uid: 141828 topic_id: 29188 reply_id: 329188[/import]

Without combing through all your code I would guess that you have an error.

Are you getting anything in the terminal? [import]uid: 52491 topic_id: 29188 reply_id: 117386[/import]

Sorry that wasn’t that clear - when I said an “error” I meant an error that was unrelated to the buttons but occurred before they were positioned and affected that :wink: [import]uid: 52491 topic_id: 29188 reply_id: 117387[/import]

Hi there peach,

Thank you for the reply. I am not receiving any output to the terminal until I click the buttons in the simulator which just print that the buttons were clicked, except for the “New Game” button which transitions over to the gamemode.lua scene.

As a side note … something I’ve just noticed while running the app on the actual device is that the splashscreen transition over to the mainmenu doesn’t actually show the transition animation: storyboard.gotoScene( “mainmenu”, “zoomOutInFadeRotate”, 500 ); … but it does in the simulator.

I wonder if it’s something to do with the audio I’m playing or the way I’m transitioning between these two scenes? … The splashscreen.ogg sound is a five second clip…

Edit: I tried removing the audio and still the same result.

Edit2: So weird - I tried just bypassing the splashscreen totally with storyboard.gotoScene( “mainmenu” ); and when it loads on the phone I get an Error: “This application has been corrupted.” … Weird! [import]uid: 141828 topic_id: 29188 reply_id: 117390[/import]

Wow,

So I figured out what was going on and it is absolutely, positively simple. Check out this button:

newGameButton = ui.newButton{
default = “images/redbutton.png”,
over = “images/redButtonover.png”,
onRelease = newGameButtonReleased,
id = “newGameButton”,
text = “New Game”,
font = “Astron Boy”,
textColor = { 51, 51, 51, 255 },
size = 22,
emboss = true
}
screenGroup:insert( newGameButton );

… The problem was I had a capital B in the over image name instead of a lowercase B.

At least I learned a lot over the last few days! LOL

Not sure how it works but if you could please mark this one as resolved - and thank you for your help peach! [import]uid: 141828 topic_id: 29188 reply_id: 117404[/import]

Ah, capital letters, the bane of many a existence! Well done on figuring it out, marking as resolved - thanks for updating :slight_smile:

Peach [import]uid: 52491 topic_id: 29188 reply_id: 117512[/import]