Physics - Touch - Accelerometer Example

New to Moai? Get started here with our best tips and tutorials.

Physics - Touch - Accelerometer Example

Postby milleniummike » Wed Dec 07, 2011 9:36 pm

Features

Uses touch input or mouse input

On release of mouse or touch applies physics impulse to player ball using distance (similar effect to Corona SDK's pool example)

Uses the camera limiter to follow player ball

Adjusts gravity with accelerometer (similar effect to Corona SKD's tumbler example)



http://pastebin.com/Y1rVZt32
milleniummike
 
Posts: 51
Joined: Mon Dec 05, 2011 2:26 am

Re: Physics - Touch - Accelerometer Example

Postby bonozogames » Wed Feb 29, 2012 5:58 pm

Thank you for this!
User avatar
bonozogames
 
Posts: 170
Joined: Sat Nov 05, 2011 9:17 pm
Location: Tulsa, OK

Re: Physics - Touch - Accelerometer Example

Postby Codex » Fri Mar 02, 2012 11:49 pm

milleniummike wrote:Features

Uses touch input or mouse input

On release of mouse or touch applies physics impulse to player ball using distance (similar effect to Corona SDK's pool example)

Uses the camera limiter to follow player ball

Adjusts gravity with accelerometer (similar effect to Corona SKD's tumbler example)



http://pastebin.com/Y1rVZt32


Hi milleniummike

Thanks for this! I am a newbie and contributions like this help me a lot to learn.

I run your code sucesfully, but in the simulator, I can only see a small part of the green rectangle/square. It seems like my simulator only sees a small portion of the 960, 480 view. Should my project be built for 960, 480 as well?

It seems like I have a 480 x 240 window on a 960 x 480 "world".

Thanks!
Codex
 
Posts: 4
Joined: Wed Feb 01, 2012 11:24 am

Re: Physics - Touch - Accelerometer Example

Postby mikegriffin » Mon Mar 05, 2012 1:18 am

Hi

I now use the following code to get the screen size of the target device - if it can't get it then it defaults to 800 x 480.
Hope this helps.

Code: Select all
  1.  

  2. screen_width,screen_height=MOAIEnvironment.getScreenSize()

  3. if screen_width==0 then screen_width=800 end

  4. if screen_height==0 then screen_height=480 end

  5. MOAISim.openWindow ( "test", screen_width, screen_height )

mikegriffin
 
Posts: 68
Joined: Thu Feb 02, 2012 12:04 pm


Return to New Users

Who is online

Users browsing this forum: No registered users and 0 guests

cron

x