I have a problem that I just cannot understand; probably because I do not have the right knowledge.
I have a TMX card made in Tiled. The map is larger than the screen size (32x32pixels and 100x100 tiles). I want you to be able to move the map by scrolling the screen.
I looked at various tutorials online and looked at paddle.m example, but still can't get it to work. All the tutorials I came across are focused on moving the focused sprite around the map ... Again, I want you to be able to move the map by scrolling / moving the screen; same as scrolling your iPod or moving the image around.
Can anyone help?
Here is my ccTouchMoved code
-(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint touchPointMap = [touch locationInView: [touch view]]; touchPointMap = [[CCDirector sharedDirector] convertToGL: touchPointMap]; touchPointMap = [self convertToNodeSpace: touchPointMap]; CCLOG(@"Touch Point Map %lf, %lf", touchPointMap.x, touchPointMap.y); self.position = CGPointMake(touchPointMap.x, touchPointMap.y); }
To illustrate the problem that I see on the screen when I scroll the screen using the code above: It seems that if I touch the center of the screen, the lower left corner of the map will move to this touching coordinate and will move with my touch until my touch raised. The bottom left corner of the map will always move to where I start the touch. In addition, when the card moves, it flashes like crazy and, if moved excessively, completely disappears.
Thanks again, really appreciate. Best and best wishes, Hiro
source share