46.1 Download Requirements and Update The Android SDK: Fortysix
46.1 Download Requirements and Update The Android SDK: Fortysix
FORTYSIX
In this chapter we will learn about Building RingLibSDL Games for Mobile.
So we can create packages (*.apk) for the applications that are developed using Ring Game Engine for 2D Games.
380
Ring Documentation, Release 1.2
You can add the source code (*.ring) and Images/Sound Files to the assets folder.
You will find the Flappy Bird 3000 Game ready for building.
The execution starts from the start.ring file
load "game2.ring"
Then we can create the package (*.apk) using the next command.
ant debug
FORTYSEVEN
In this chapter we will learn how to use the Qt framework classes in our Ring applications to create Desktop and
Mobile Applications.
In this example we will create an application to ask the user about his/her name. When the user type the name in the
textbox then click on Say Hello button, the textbox value will be updated by adding Hello to the name.
Load "guilib.ring"
setwindowtitle("Hello World")
setGeometry(100,100,370,250)
show()
}
383
Ring Documentation, Release 1.2
exec()
}
Func pHello
lineedit1.settext( "Hello " + lineedit1.text())
Func pClose
MyApp.quit()
Program Output:
At first we type the name in the textbox
The next example is just an upgrade to the previous application to use the vertical layout.
Load "guilib.ring"
setwindowtitle("Hello World")
setGeometry(100,100,400,130)
label1 = new qLabel(win1) {
settext("What is your name ?")
setGeometry(10,20,350,30)
setalignment(Qt_AlignHCenter)
}
btn1 = new qpushbutton(win1) {
setGeometry(10,200,100,30)
settext("Say Hello")
setclickevent("pHello()")
}
btn2 = new qpushbutton(win1) {
setGeometry(150,200,100,30)
settext("Close")
setclickevent("pClose()")
}
lineedit1 = new qlineedit(win1) {
setGeometry(10,100,350,30)
}
layout1 = new qVBoxLayout() {
addwidget(label1)
addwidget(lineedit1)
addwidget(btn1)
addwidget(btn2)
}
win1.setlayout(layout1)
show()
}
exec()
Func pHello
lineedit1.settext( "Hello " + lineedit1.text())
Func pClose
MyApp.quit()
New qApp {
setwindowtitle("QTextEdit Class")
setGeometry(100,100,500,500)
new qtextedit(win1) {
setGeometry(10,10,480,480)
show()
}
exec()
}
During the runtime we can paste rich text in the qtextedit widget
New qApp {
setGeometry(100,100,400,400)
show()
}
exec()
}
func pWork
btn1.settext(string(list1.currentrow()))
func pWork2
list1 {
takeitem(currentrow())
}
Another Example:
Load "guilib.ring"
New qApp {
setGeometry(100,100,500,400)
setcurrentrow(3,2)
win1.setwindowtitle("Items Count : " + count() )
}
show()
}
exec()
}
func pWork
nbrOfItems = list1.count()
curItemNbr = list1.currentrow()
curValue = list1.item(list1.currentrow()).text()
func pWork2
list1 {
takeitem(currentrow())
nbrOfItems = count()
curItemNbr = currentrow()
curValue = item(currentrow()).text()