You are writing a comment about Touch Detection in Cocos2d iPhone, here is a quick summary:
A quick look at three different approaches for implementing touch detection using the Cocos2d iPhone library. There are a number of snippets here, and I imagine it would be rather confusing to approach without a basic understanding of ObjC and Cocos2d iPhone.
You are responding to this comment written by Steve on January 3rd 2009, 19:11.
I'm pretty new to objective-c/cocoa/iphone programming here but have found the few resources I have found for cocos2d to be pretty helpful. I'm trying to get the example above to work.. I subclassed Sprite and implimented a simple rect method like this..
- (CGRect) rect {
float x = [self position].x;
float y = [self position].y;
float h = [self contentSize].height;
float w = [self contentSize].width;
CGRect aRect = CGRectMake(x,y,w,h);
return aRect;
}
This returns a rect, but my limited knowledge is preventing me from debugging it. I'm trying to capture a touch inside the sprite using the CGRectContainsPoint method descibed.. I have an NSLog telling me that the sprite was touched, but it registers in what seems like the same SIZED box, but not where the sprite actually is.
Can anyone help me by telling me how I might 'trace' the CGRect so I can see exactly where it's placing it in relation to my sprite or maybe if they know why the CGRect and my sprite might be in different locations? It almost seems like 0,0 is not in the same places for the Sprite and the CGRect.. Thanks!
Please be aware that comment forms go stale after one hour.
Comments may make use of LifeFlow MarkDown. Raw html will be escaped.
Quick Introduction to LifeFlow MarkDown Syntax
A highlighted code block:
Other common languages work as well: scheme, python, java, html, etc.
Other markdown syntax: