Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-21-2011, 10:28 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 5
venkateshf1 is on a distinguished road
Question Ball Animation in Landscape mode using uiaccelerometer

0 down vote favorite
share [fb] share [tw]


I'm animating a ball on the screen in portrait mode using uiaccelerometer.Its working fine, now I want the same to work in landscape mode.When i tried to use the same part of code(for portrait) in the landscape mode it gives me a weird result, seems to be completely wrong. I am breaking my head in to this. Any help will be appreciated.My code below for poratrit view.

(void)accelerometerUIAccelerometer *)accelerometer didAccelerateUIAcceleration *)acceleration {
// apply acceleration to velocity

NSTimeInterval elapsedTime = acceleration.timestamp - lastAccelTimestamp;
ballVelocityX = ballVelocityX + (acceleration.x * MAX_ACCEL_PER_SEC * elapsedTime);
ballVelocityY = ballVelocityY - (acceleration.y * MAX_ACCEL_PER_SEC * elapsedTime);

if (lastAccelTimestamp > 0) {
// recalc ball position
ballX += (ballVelocityX * elapsedTime); // ballX is CGFloat
ballY += (ballVelocityY * elapsedTime); // ballY is CGFloat
// update view
[ballView setCenter:CGPointMake(ballX, ballY)];
} lastAccelTimestamp = acceleration.timestamp;

}
venkateshf1 is offline   Reply With Quote
Reply

Bookmarks

Tags
animation, ball, landscape, uiaccelrometer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 379
10 members and 369 guests
apatsufas, comicool, Creativ, Dalia, dansparrow, LunarMoon, mer10, Murphy, pbart, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:59 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0