2014-06-23 1 views
4

버튼의 스프라이트 프레임을 설정해야합니다.cocos2d 3.x CCButton 스프라이트 프레임 이미지가 왜곡되고 콜백/블록이 작동하지 않음을 설정합니다.

나는 그것이 작동하고 생성자 사용하는 경우 :

CCSprite *sprite = [CCSprite spriteWithImageNamed:@"but.png"]; 
    CCButton *button = [CCButton buttonWithTitle:@"" spriteFrame:sprite.spriteFrame]; 
    [button setBlock:^(id sender){...}] 

enter image description here

을하지만, 이후

CCButton *button = [CCButton buttonWithTitle:@""]; 
    button.background.spriteFrame = sprite.spriteFrame; 

또는이

[button setBackgroundSpriteFrame:sprite.spriteFrame forState:CCControlStateNormal]; 
를 스프라이트 프레임을 설정해야 할 때

둘 다 작동하지 않고 결과가 왜곡 된 이미지이며 콜백 함수 또는 블록이 호출되지 않습니다.

enter image description here

+0

이것은 버그 일 수 있습니다. – LearnCocos2D

답변

0

안녕하세요이 저도 같은 문제를 겪고하고 해결책을 발견했다. 그냥 다음과 같이하십시오.

CCSpriteFrame *spriteFrame = [CCSpriteFrame frameWithImageNamed:@"Icon-Small.png"]; 
button = [CCButton buttonWithTitle:@"" spriteFrame:spriteFrame]; 

매력처럼 작동합니다.