Landscape character accelerometer control.

OK, so what happens now is when I tilt my device up it goes left and when I tilt it down it goes right. Here is my code:

[lua]function onTilt(event)

mandown.x = mandown.x+30*-(event.xGravity)

print(event.xGravity)

end

Runtime:addEventListener (“accelerometer”, onTilt) [import]uid: 184688 topic_id: 32266 reply_id: 128962[/import]

Try yGravity. I think the controls don’t rotate to landscape [import]uid: 7911 topic_id: 32266 reply_id: 128963[/import]

OK hold on. [import]uid: 184688 topic_id: 32266 reply_id: 128964[/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]

OK hold on. [import]uid: 184688 topic_id: 32266 reply_id: 128965[/import]

OMG THANKS IT WORKS!

Although it is a little glitchy it works!

Let me know if you want to see anything!
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128968[/import]

Ur welcome. [import]uid: 7911 topic_id: 32266 reply_id: 128969[/import]

U can try adjusting the accelerometer interval
http://docs.coronalabs.com/api/library/system/setAccelerometerInterval.html [import]uid: 7911 topic_id: 32266 reply_id: 128971[/import]

Yea I did and it works, now I just have to figure out how to get perfect collision detection working.
Also my character right now is round blank circle. Do you know how to switch the characters rotation say on a button press or the change in gravity either one would work but if button press if easier just show that. Right now I have two buttons(up and down) to change the gravity. If I could make the character be upside down when I press up, that would be helpful.
Thanks again,

Avery [import]uid: 184688 topic_id: 32266 reply_id: 128972[/import]

Sorry I figured out how to flip it.
Avery [import]uid: 184688 topic_id: 32266 reply_id: 128973[/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:

http://google.com

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]