Hi everyone.
I'm developing a game with 2 modes that use 2 types of screen: Landscape and Portrait.
I designed 2 buttons in Main Menu to select one of these 2 modes.
But i don't know how to switch them. Someone help me!
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Switch Landscape to Portrait mode?
Hi,
The user changes orientation by tilting the device which the code will have to detect. Then based on the current orientation, you redraw the placement of objects on your screen. These events are only sent for certain devices with accelerometer support.
if you are developing for android, then you definitely want to check this twice.
I mean i have 2 modes: the first likes Ninja Fruit (Landscape) and the second likes Doodle Jump (Portrait).
I want to switch 2 modes when press a button WITHOUT TILTING DEVICE but i cannot find any code in API or forum for this function. I'm still stuck here.
build.settings file:
1 2 3 4 5 6 7 8 9 | orientation = { default = "landscapeRight", content = "landscapeRight", supported = { "landscapeRight" }, }, |
The following things are setting for portrait mode.
If you are force-fully set the game mode Portrait then check this first in new mode(Portrait Mode) file :
if (system.orientation == "landscapeLeft") or (system.orientation == "landscapeRight") then
localGroup.rotation = -90
localGroup.x = 0
localGroup.y = 768
end
Set all the objects co-ordinates of new mode(Portrait Mode) in portrait form.
This will show ur game in portrait mode even your device in landscape mode.
and also don't forget to set the localGroup rotation in Runtime:addEventListener . like
local function onOrientationChange ( event )
if (event.type == "landscapeLeft") or (event.type == "landscapeRight") then
print(event.type)
localGroup.rotation = -90
localGroup.x = 0
localGroup.y = 0
elseif (event.type == "portrait") or (event.type == "portraitUpsideDown") then
print(event.type)
localGroup.rotation = 360
localGroup.x = 0
localGroup.y = 0
end
return true
end
Runtime:addEventListener("orientation", onOrientationChange )
Little modification on above thing for set in to Landscape Mode.
build.setting :
settings =
{
orientation =
{
default = "portrait",
supported = { "landscapeLeft","landscapeRight","portraitUpsideDown" },
},
}
It's work very well in my game , i hope it's also helpful to u.
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
Touch listener breaks on double click in windows simulator
Playing with textures and masks
Eating our own dog food: How we built the Photoshop 20th Anniversary iPhone App in three days.
Looking for an Experienced Programmer To Work With Me And My Team!
Cancelling a touch event
Essential Mac apps for Corona development
Getting error in ADB Logcat about not being able to open images.
Mutant ABCs now Available
[SOLVED]icon dimensions (0 x 0) don't meet the size requirements