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 > Jobs and Commerce > Help Wanted

Reply
 
LinkBack Thread Tools Display Modes
Old 09-29-2010, 05:08 PM   #1 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default Need help with Accelerometer in Portrait mode!!! Will pay someone if it works!!!

Please helppp. I will pay if it ends up working. I need it to work in Cocos 2d thankss so much!!
Chessin is offline   Reply With Quote
Old 09-30-2010, 06:36 PM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

You're going to need to give more information than that.
harrytheshark is offline   Reply With Quote
Old 09-30-2010, 07:44 PM   #3 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

There are no tutorials on how to put it in portrait mode. This is my first time using the accelerometer, and the only tutorials are the ones in landscape so I just copied the code and tried changing the values like 50 times and it just doesn't work. Ex: it gets stuck, doesn't move left or right, unreaponsive. Can you please help me?
Chessin is offline   Reply With Quote
Old 10-01-2010, 04:54 AM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

I'd rather try helping you first than just taking your money.

Post the code you're having trouble with.
harrytheshark is offline   Reply With Quote
Old 10-01-2010, 12:43 PM   #5 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Orange County, California
Posts: 36
ShayansMind is on a distinguished road
Send a message via AIM to ShayansMind Send a message via Skype™ to ShayansMind
Default ...

Well can you atleast launch the app in portrait
ShayansMind is offline   Reply With Quote
Old 10-01-2010, 07:04 PM   #6 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by harrytheshark View Post
I'd rather try helping you first than just taking your money.

Post the code you're having trouble with.
Code:
#import "Paddle.h"
#import "Sprite.h"
#import "cocos2d.h"

@implementation Paddle
-(id)init{
	self = [super init];
	if (self != nil) {
		Sprite *paddle = [Sprite spriteWithFile:@"paddle.png"];
		paddle.position = ccp(0, 0);
		self.position = ccp(240, 20);
		[self addChild:paddle];
		self.isAccelerometerEnabled = YES;
		[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 30)];

	}
	return self;
}

- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration{
	float acelx = -acceleration.y;
	float x = acelx*20;
	

	
	if (self.position.x > 0 && self.position.x < 480) {
		self.position = ccp(self.position.x+x, self.position.y);
	}
	if (self.position.x < 55) {
		self.position = ccp(56, self.position.y);
	}
	if (self.position.x > 435) {
		self.position = ccp(434, self.position.y);
	}
	
	
	
	if (self.position.x < 55 && x > 1) {
		self.position = ccp(self.position.x+x, self.position.y);
	}
	
	if (self.position.x > 435 && x < 0) {
		self.position = ccp(self.position.x+x, self.position.y);
	}
}

@end
Do you know what the values are supposed to be? Is there another way to do this? Thanks

Also if you need different/more code tell me.
Chessin is offline   Reply With Quote
Old 10-01-2010, 11:08 PM   #7 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
Kalimba is on a distinguished road
Default

Quote:
Originally Posted by harrytheshark View Post
I'd rather try helping you first than just taking your money.
From what I can see, the fix is simple and obvious, and I tried to get the guy pointed in the right direction in this earlier thread: http://www.iphonedevsdk.com/forum/ip...lp-please.html, but apparently the "eureka moment" is not quite in reach.
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 10-01-2010, 11:19 PM   #8 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by Kalimba View Post
From what I can see, the fix is simple and obvious, and I tried to get the guy pointed in the right direction in this earlier thread: http://www.iphonedevsdk.com/forum/ip...lp-please.html, but apparently the "eureka moment" is not quite in reach.
Kalimba, seriously ... not to be mean but Im new to development and your advanced talk about all of this is like another language to me. I did look at the the page you sent me and it didnt help so I was hoping to get someone else to help me.
Chessin is offline   Reply With Quote
Old 10-01-2010, 11:21 PM   #9 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by ShayansMind View Post
Well can you atleast launch the app in portrait
Yes but then there are problems with the accelerometer moving, like it gets stuck, goes off the screen etc...
Chessin is offline   Reply With Quote
Old 10-02-2010, 03:32 AM   #10 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Kalimba gave you exactly what you need to do in a not-so-complicated way.

Think about this logically. You want the paddle to move from left to right, right to left when the screen is in portrait. If you take a look at the diagram in the other thread, you'll see that it's the x-axis that responds to that kind of tilt movement.

You then need to look at your existing code, and at the numbers used there. The maximum width in portrait is 320, as opposed to 480 in landscape. This should give an idea of what you need to change in the if statements.

You could also try getting rid of if statements all togther and just seeing how you object responds with raw accelerometer values. Then slowly but surely put the if statements back in, noting how the object responds now.

Of course you can just pay someone to do this for you, and it's a 30 second job, but you'll be forever stuck in a position where you don't know anything (and it's a waste of money).

You can't go through software development asking other people for code and just sticking it in, you need to understand it to better yourself. And if you don't feel ready for that yet, take a few years to mature and then come back with a fresh persepective. This of course doesn't just apply to you personally; there are a lot of people on here that just ask for code, without wanting to understand.

It's up to you now.
harrytheshark is offline   Reply With Quote
Old 10-02-2010, 10:41 AM   #11 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by harrytheshark View Post
Kalimba gave you exactly what you need to do in a not-so-complicated way.

Think about this logically. You want the paddle to move from left to right, right to left when the screen is in portrait. If you take a look at the diagram in the other thread, you'll see that it's the x-axis that responds to that kind of tilt movement.

You then need to look at your existing code, and at the numbers used there. The maximum width in portrait is 320, as opposed to 480 in landscape. This should give an idea of what you need to change in the if statements.

You could also try getting rid of if statements all togther and just seeing how you object responds with raw accelerometer values. Then slowly but surely put the if statements back in, noting how the object responds now.

Of course you can just pay someone to do this for you, and it's a 30 second job, but you'll be forever stuck in a position where you don't know anything (and it's a waste of money).

You can't go through software development asking other people for code and just sticking it in, you need to understand it to better yourself. And if you don't feel ready for that yet, take a few years to mature and then come back with a fresh persepective. This of course doesn't just apply to you personally; there are a lot of people on here that just ask for code, without wanting to understand.

It's up to you now.
I actually found a whole new code for the accelerometer
But in the bold I get Object cannot be set - either readonly property or no setter found

Code:
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate: (UIAcceleration *)acceration {
	if (acceration.x < 60) {
		XM += 1;
		AccelPoint.x = XM;
		Square.center = AccelPoint;
	}
	if (acceration.x < 60) {
		XM -= 1;
		AccelPoint.x = XM;
		Square.center = AccelPoint;
	}
	if (acceration.y < 60) {
		XM += 1;
		AccelPoint.x = YM;
		Square.center = AccelPoint;
	}
	if (acceration.y < 60) {
		XM -= 1;
		AccelPoint.x = YM;
		Square.center = AccelPoint;
	}
	X = acceration.x = 58;
	XM -= X;
	AccelPoint.x = XM;
	
	Y = acceration.y = 58;
	YM-= Y;
	AccelPoint.y = YM;
	
	Square.center = AccelPoint;
	if (AccelPoint.x < 50.0) {
		AccelPoint.x = 50.0;
	}
	if (AccelPoint.x < 270.0) {
		AccelPoint.x = 270.0;
	}
	Square.center = AccelPoint;
	if (AccelPoint.y < 50.0) {
		AccelPoint.y = 50.0;
	}
	if (AccelPoint.y < 410.0) {
		AccelPoint.y = 410.0;
	}
	Square.center = AccelPoint;
}
in the .h

Code:
CGPoint AccelPoint;
	IBOutlet UIImageView *Square;
	NSInteger X;
	NSInteger Y;
	NSInteger XM;
	NSInteger YM;
Chessin is offline   Reply With Quote
Old 10-02-2010, 10:55 AM   #12 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

It's pretty blatantly obvious what's wrong...
harrytheshark is offline   Reply With Quote
Old 10-02-2010, 11:57 AM   #13 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by harrytheshark View Post
It's pretty blatantly obvious what's wrong...
Ok, so how would I fix it, Im new to this and not really sure what to do... Please. Help
Chessin is offline   Reply With Quote
Old 10-02-2010, 12:09 PM   #14 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Code:
Y = acceration.y = 58;
That doesn't look odd to you?
harrytheshark is offline   Reply With Quote
Old 10-02-2010, 03:14 PM   #15 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by harrytheshark View Post
Code:
Y = acceration.y = 58;
That doesn't look odd to you?
Your right, that does look kind of odd. I got this code off the Internet so I'm not really sure of it myself. Should that line of code be Commented out or should it be modified to something else but I have no idea what those lines of code should be.
Chessin is offline   Reply With Quote
Old 10-02-2010, 04:59 PM   #16 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 580
ChrisL is on a distinguished road
Default

Quote:
Originally Posted by Chessin View Post
Your right, that does look kind of odd. I got this code off the Internet so I'm not really sure of it myself. Should that line of code be Commented out or should it be modified to something else but I have no idea what those lines of code should be.
Chessin, I know that things can be overwhelming when you're first starting out, but you'll find that the best way to get helpful responses is to ask questions that really demonstrate that you're making a serious effort to learn. Saying "I'm new to development, can you do it for me?" every time you're confronted with a new problem is just going to cause experienced developers to write off helping you as a waste of time, and that would be a shame.

The problems you're getting stuck on are such fundamental concepts in coding that you need to dedicate some real time to mastering them. Using tutorials and code that others have written will only help you learn if you're willing to study it until you understand exactly what each and every line does. If you can't, then you need to step back even further, pick up a book, and review the basics. Otherwise, it's like setting out to build a skyscraper without knowing how to use a hammer.

Software development is hard, and it's perfectly normal to encounter problems that take days or even weeks to figure out how to solve. You can't just throw up your hands every time things don't make sense after a few hours of trying and expect someone else to solve your problems for you. Don't be so easy on yourself. If something doesn't make sense, read books, read the documentation, do google searches for articles or tutorials, or spend time practicing with simpler, throwaway projects until you really have the basic concepts down. Before you ask for help, see if there's something else you could try or someplace else you could look. If you do this, you'll find that you're capable of solving a lot more of your own problems than you might think, and when you do ask questions, they'll demonstrate much more insight and be more likely to get helpful responses.
ChrisL is offline   Reply With Quote
Reply

Bookmarks

Tags
cocos accelerometer

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: 374
20 members and 354 guests
Abidullah, AppRocketeer, baja_yu, Brandt, BSH, Domele, Droverson, Duncan C, Free App Monster, givensur, iAppDeveloper, locombiano89, MasterX, Meoz, Punkjumper, SLIC, stanny, stevenkik, Tomsky, wassupdoc
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,646
Threads: 94,111
Posts: 402,867
Top Poster: BrianSlick (7,990)
Welcome to our newest member, locombiano89
Powered by vBadvanced CMPS v3.1.0

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