I'm writing a program for a mobile app development class that I am taking. The app involves me placing 2 buttons on the screen. I know that when I put /2 it places it in the middle, and when I put /3 it places the button a third of the way from the left of the screen. Since I need two buttons I would like to put one a third of the the way from the left(which I know how to do), and a third from the right(which I don't know how to do). What should I put to accomplish that?
My code snippet:
myRedButton.x = display.contentWidth /3
myRedButton.y = display.contentHeight -50
myGreenButton.x = display.contentWidth /2
myGreenButton.y = display.contentHeight -100
I'm new to the mobile app programming scene, so keep it simple. Thanks!
Try this:
local myGreenButton = display.newRect(0,0,50,50)
myGreenButton.x = display.contentWidth- (display.contentWidth/3)
myGreenButton.y = 100
OR simply,
local myGreenButton = display.newRect(0,0,50,50)
myGreenButton.x = (2/3)*display.contentWidth
myGreenButton.y = 200
Keep Coding.............. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With