2
首先是我的touchesBegan函數,然後是存儲我的對象的值的結構。我有這些對象的數組,我試圖弄清楚當我觸摸屏幕時,如果我觸摸屏幕上的對象。Opengl Iphone SDK:如何判斷您是否觸摸屏幕上的對象?
我不知道是否需要通過遍歷所有對象並確定是否以這種方式觸摸對象或者可能存在更簡單更有效的方式來執行此操作。
這是如何處理的?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesEnded:touches withEvent:event];
UITouch* touch = ([touches count] == 1 ? [touches anyObject] : nil);
CGRect bounds = [self bounds];
CGPoint location = [touch locationInView:self];
location.y = bounds.size.height - location.y;
float xTouched = location.x/20 - 8 + ((int)location.x % 20)/20;
float yTouched = location.y/20 - 12 + ((int)location.y % 20)/20;
}
typedef struct object_tag // Create A Structure Called Object
{
int tex; // Integer Used To Select Our Texture
float x; // X Position
float y; // Y Position
float z; // Z Position
float yi; // Y Increase Speed (Fall Speed)
float spinz; // Z Axis Spin
float spinzi; // Z Axis Spin Speed
float flap; // Flapping Triangles :)
float fi; // Flap Direction (Increase Value)
} object;
看看iPhone是否支持glRenderMode(GL_SELECT)。如果是這樣,谷歌glSelectBuffer文檔和教程。 – SigTerm 2010-05-24 02:57:25
很感謝。我會去做。 – TheGambler 2010-05-24 13:06:27
glRenderMode似乎沒有被iPhone SDK支持。 – TheGambler 2010-05-25 13:37:34