나는 정말 여기에 붙어 있습니다. 내 응용 프로그램은 가로보기이며 한 화면에서 내 지침 이미지를 스크롤 할 수 있기를 원합니다. 이 이미지를 스프라이트로 추가했습니다. 먼저 스크롤 효과를 다른 사이트에서 사용할 수있게하려고했지만 곧 스크롤이 스프라이트 이미지가 아닌 전체 화면에서 수행되는 것을 보았습니다. 그런 다음 스프라이트를 y 축 (위아래)으로 드래그하여 스크롤 효과를 구현했습니다. 불행히도 나는 어딘가에있는 것들을 엉망으로 만들고있다. 왜냐하면 스프라이트의 한 부분 (높이 320 픽셀의 화면에만 표시됨)이 드래그되고 스프라이트의 나머지 부분이 보이지 않기 때문이다. 초기화 층 기능에COCOS2D의 스크롤 효과와 같이 특히 큰 스프라이트를 위아래로 드래그
을 다음과 같이 코드는 내가
//Add the instructions image
instructionsImage = [Sprite spriteWithFile:@"bkg_InstructionScroll.png"];
instructionsImage.anchorPoint = CGPointZero;
[self addChild:instructionsImage z:5];
instructionsImage.position = ccp(40,-580);
oldPoint = CGPointMake(0,0);
self.isTouchEnabled = YES;
//The touch functions are as follows
- (BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
// Move me!
if(touch && instructionsImage != nil) {
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedPoint = [[Director sharedDirector] convertCoordinate:location];
CGPoint newPoint = CGPointMake(40, (instructionsImage.anchorPoint.y+ (convertedPoint.y - oldPoint.y)));
instructionsImage.position = newPoint;
return kEventHandled;
}
return kEventIgnored;
}
//The other function
- (BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
// Move me!
if(touch && instructionsImage != nil) {
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedPoint = [[Director sharedDirector] convertCoordinate:location];
oldPoint = convertedPoint;
return kEventHandled;
}
return kEventIgnored;
}
"ccp (instructionsImage.position.y, ...)"는 "ccp (instructionsImage.position.x, ...)"가되어야하지만 예,이 방법이 효과적입니다. – Evan