Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I place an object on the other side of the screen

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!

like image 465
user1641187 Avatar asked Nov 01 '22 06:11

user1641187


1 Answers

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.............. :)

like image 92
Krishna Raj Salim Avatar answered Nov 12 '22 14:11

Krishna Raj Salim