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 03-19-2011, 06:13 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 80
Chris1979 is on a distinguished road
Default error: incompatible type for argument 1 of 'movePiece:inDirectionX:inDirectionY:withA

Hey guys!

I get the following error message on all 4 cases in the switch function:

error: incompatible type for argument 1 of 'movePiece:inDirectionX:inDirectionY:withAnimation :

why is that?

(I tried to google for the issue but couldnīt find anything.)

Code:
-(void) movePiece:(UIImageView *)brickgrid withAnimation:(BOOL) animate{
	
	NSLog(@"MovePiece");
	switch ( [self validMove:brickgrid] ) {
		case UP:
			[self movePiece:brickgrid 
			   inDirectionX:0 inDirectionY:-1 withAnimation:animate];
			break;
		case DOWN:
			[self movePiece:brickgrid 
			   inDirectionX:0 inDirectionY:1 withAnimation:animate];
			break;
		case LEFT:
			[self movePiece:brickgrid
			   inDirectionX:-1 inDirectionY:0 withAnimation:animate];
			break;
		case RIGHT:
			[self movePiece:brickgrid 
			   inDirectionX:1 inDirectionY:0 withAnimation:animate];
			break;
		default:
			break;
	}
}

I also get the following error message on the -(void) movePiece: (UIImageView)brick inDirectionX: (NSInteger) dx inDirectionY: (NSInteger) dy withAnimation: (BOOL) animate{ part

error: can not use an object as parameter to a method

Any suggestions?

Code:
 -(void) movePiece: (UIImageView)brick inDirectionX: (NSInteger) dx inDirectionY: (NSInteger) dy withAnimation: (BOOL) animate{
	
(I havenīt done this part yet)

}
The -(void) movePiece: (UIImageView *)brickgrid withAnimation: (BOOL) animate retrieves information from this method

Code:
-(void) getPieceAtPoint:(CGPoint) point{
	
	CGRect touchRect = CGRectMake(point.x, point.y, 1.0, 1.0);
	
	NSLog(@"getPieceAtPoint");
	for (int y = 0; y < BRICKHEIGHT; y++){
				
		for (int x = 0; x < BRICKWIDTH; x++){
				
			if( CGRectIntersectsRect([grid[x][y] frame], touchRect) ){
			
				[self movePiece:grid[x][y] withAnimation:YES];
				NSLog(@"X:  %d" , x);
				NSLog(@"Y:  %d" , y);
			}	
		}
	}
}
Thanx in advance!

Last edited by Chris1979; 03-19-2011 at 06:18 AM.
Chris1979 is offline   Reply With Quote
Old 03-19-2011, 07:17 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

The problem of 2 errors is related
Quote:
-(void) movePiece: (UIImageView)brick inDirectionX: (NSInteger) dx inDirectionY: (NSInteger) dy withAnimation: (BOOL) animate{
Yes, you can't use an object, use a reference to that object, so

Quote:
-(void) movePiece: (UIImageView *)brick inDirectionX: (NSInteger *) dx inDirectionY: (NSInteger *) dy withAnimation: (BOOL) animate{
where you call this method, you are using a reference (but as you declared, should be the object and not the reference)

So just change that line and will work.
__________________

Last edited by dany_dev; 03-19-2011 at 07:23 AM.
dany_dev is offline   Reply With Quote
Old 03-19-2011, 07:49 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 80
Chris1979 is on a distinguished road
Default

Quote:
Originally Posted by dany88 View Post
The problem of 2 errors is related


Yes, you can't use an object, use a reference to that object, so



where you call this method, you are using a reference (but as you declared, should be the object and not the reference)

So just change that line and will work.
Thanx for the fast reply.

I tried it out as you posted. it work fine with the object error

But I got this message instead on the cases in the switch function:

warning: passing argument 3 of 'movePiece:inDirectionX:inDirectionY:withAnimation :' makes pointer from integer without a cast

Last edited by Chris1979; 03-19-2011 at 07:57 AM.
Chris1979 is offline   Reply With Quote
Old 03-19-2011, 08:38 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

because 0 and 1 (that you are using when calling the method), are not NSInteger objects are just primitive integers, you need to create a NSInteger or change method definition using int like

Quote:
-(void) movePiece: (UIImageView *)brick inDirectionX: (int) dx inDirectionY: (int) dy withAnimation: (BOOL) animate{
__________________
dany_dev is offline   Reply With Quote
Old 03-19-2011, 11:39 AM   #5 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 80
Chris1979 is on a distinguished road
Default

Quote:
Originally Posted by dany88 View Post
because 0 and 1 (that you are using when calling the method), are not NSInteger objects are just primitive integers, you need to create a NSInteger or change method definition using int like
Now I see it... thanks.. I appreciate it a lot...

Iīve been staring myself blind on this for way to long.

Thanks for enlightening me!

Last edited by Chris1979; 03-19-2011 at 12:29 PM.
Chris1979 is offline   Reply With Quote
Reply

Bookmarks

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: 422
5 members and 417 guests
chemistry, hussain1982, Retouchable, skrew88, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

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