I am very new to corona. I am making a platform game in landscape mode. For some reason I can get landscape character acceleration control to work. I have a character and I want him to move left to right when I tilt my device. I have figured out portrait, but if I try landscape mode, either the controls are backwards or it freaks out. This is my first post so I hope someone sees it. All I need is the correct code and an explantion of it [import]uid: 184688 topic_id: 32266 reply_id: 332266[/import]
Hi and welcome!
Take a look at the Ghosts VS Monsters sample code; this actually shows you this exact thing 
http://developer.coronalabs.com/code/ghosts-vs-monsters
Peach
[import]uid: 52491 topic_id: 32266 reply_id: 128517[/import]
I can’t seem to find what I want. If you can please just copy and paste the code in the thread I would be very thankful.
Thanks for you help!
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128529[/import]
look for a line similar to:
Runtime:addEventListener(“accelerometer”, onTilt )
find what ever is the last thing on that line onTilt in my app’s case, and then look for a line that is like:
local function onTilt(event)
or
function onTilt(event)
or
onTilt = function(event)
(there are several different ways to write it!!!)
The code below this line should be the code that lets you read the acclerometer.
[import]uid: 19626 topic_id: 32266 reply_id: 128534[/import]
Hi and welcome!
Take a look at the Ghosts VS Monsters sample code; this actually shows you this exact thing 
http://developer.coronalabs.com/code/ghosts-vs-monsters
Peach
[import]uid: 52491 topic_id: 32266 reply_id: 128517[/import]
I still can’t find it can someone please just put the code in the form I’m kind of lazy but I also can’t find it.
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128633[/import]
I can’t seem to find what I want. If you can please just copy and paste the code in the thread I would be very thankful.
Thanks for you help!
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128529[/import]
look for a line similar to:
Runtime:addEventListener(“accelerometer”, onTilt )
find what ever is the last thing on that line onTilt in my app’s case, and then look for a line that is like:
local function onTilt(event)
or
function onTilt(event)
or
onTilt = function(event)
(there are several different ways to write it!!!)
The code below this line should be the code that lets you read the acclerometer.
[import]uid: 19626 topic_id: 32266 reply_id: 128534[/import]
I still can’t find it can someone please just put the code in the form I’m kind of lazy but I also can’t find it.
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128633[/import]
I went through everything and I couldn’t find anything. I don’t mean to be rude but if there is no way to do it just tell me but right now these forums seem really unhelpful. Unless someone can show me how to do it I think I will just try to create 2 invisible buttons. One on each side so if you press on the left you go left and vice versa.
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128888[/import]
@agollnick1, the Corona SDK forums are among the most helpful on the Internet. The forums here are community supported. Yes some staff members do respond from time to time but its mostly us community members who volunteer our time to help. We all have jobs, lives, family and other activities and we respond as we are able too.
We also appreciate it when people take a little initiative to help themselves and not just ask for handouts.
Corona Labs does offer paid support if you want to get something that the community is not providing. See:
http://www.coronalabs.com/products/support-training/
If I’m not mistaken, Ghost vs. Monsters doens’t use the accelerometer. You’re more interested in Tilt Monster I think. Go to:
and search for: corona sdk accelerometer tutorials
The first 5 hits will all give you great starts on building an accelerometer based game.
[import]uid: 19626 topic_id: 32266 reply_id: 128907[/import]
All I am trying to say is that I have tried everything people said and nothing has worked. I looked at Tilt Monster and that is way out of my league. I also googled corona sdk accelerometer tutorials and lot of variations of that and no one can show me how to simply move an object left to right when you tilt the device in landscape mode. I feel that I have to repeat myself and it should be very easy to do but no one will tell me how!
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128910[/import]
Hi Avery,
Can you paste in the code that you have that is working in portrait mode? Then, perhaps we’d be able to suggest how to modify it so that it works in landscape.
- Andrew [import]uid: 109711 topic_id: 32266 reply_id: 128912[/import]
I don’t have it in portrait at all, I just used this from my old game.
[lua]function onTilt(event)
paddle.x = paddle.x+30*(event.xGravity)
print(event.xGravity)
end
Runtime:addEventListener (“accelerometer”, onTilt) [import]uid: 184688 topic_id: 32266 reply_id: 128915[/import]
That’s basically it. What’s not working?
[import]uid: 19626 topic_id: 32266 reply_id: 128918[/import]
The controls are backwards. Before you post the corrected code please test it because I thought I’ve tried everything.
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128919[/import]
Hi Avery. Can you also post your build.settings? I’m curious what orientation parameters you’ve chosen.
- Andrew [import]uid: 109711 topic_id: 32266 reply_id: 128937[/import]
you could insert a neg. to flip the controls
paddle.x = paddle.x+30*-(event.xGravity) [import]uid: 7911 topic_id: 32266 reply_id: 128949[/import]
Here are my build.settings most of it was copied and pasted so… Here.
[lua]-- Supported values for orientation:
– portrait, portraitUpsideDown, landscapeLeft, landscapeRight
settings = {
orientation = {
default = “landscape”,
supported = { “landscape”, }
},
iphone = {
plist = {
UIStatusBarHidden = false,
UIPrerenderedIcon = true, – set to false for “shine” overlay
–UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend
–[[
– iOS app URL schemes:
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fbXXXXXXXXXXXXXX”, – example scheme for facebook
“coronasdkapp”, – example second scheme
}
}
}
–]]
}
},
–[[
– Android permissions
androidPermissions = {
“android.permission.INTERNET”,
},
]]–
} [import]uid: 184688 topic_id: 32266 reply_id: 128956[/import]
Sorry for the late response I’m 15 and well, I’m 15. So I tried jstrahan’s code and it didn’t do anything when I tilted my device. here the code.
edit: I just figured out what was wrong let me fix it and I’ll report back. [import]uid: 184688 topic_id: 32266 reply_id: 128961[/import]