엘프 가시 구역(TextureRect)과 닻점(anchorPoint)을 유연하게 사용하고 가시 구역과 닻을 결합하여 진도표를 제작합니다!
                 ;
                 :      ;
                                 ,  Kjava(J2me)   setClip  ,Android clipRect    ,   iOS      ,      cocos2d            setTextureRect;
                        ,  Himi      :
                                  ,            ,           ;                  ,            ;
               , cocos2d   CCSprite                  :
1.            ;2.        ;    :
            cocos2d  ,   HelloWorldLayer.m init         ,    :
[cpp] view plaincopy
//---     icon   
CCSprite * spriteOld =[CCSprite spriteWithFile:@"icon.png"];  
spriteOld.position=ccp(80,100);  
[self addChild:spriteOld];  
//---     30 30        
CCSprite * spriteNew =[CCSprite spriteWithFile:@"icon.png" rect:CGRectMake(0, 0, 30,30)];  
spriteNew.position=ccp(150,100);  
[self addChild:spriteNew];  
//---       30 30        
CCSprite * spriteT =[CCSprite spriteWithFile:@"icon.png"];  
[spriteT setTextureRect:CGRectMake(10, 10, 30, 30)];  
spriteT.position=ccp(230,100);  
[self addChild:spriteT];   
           3   ,            icon  ,                30 30   ,                    ,       ;                    ,                 ,        ,      ;
                                     CGRect  ,  CGrect     ,  x,y,    w,y;
      CGRect              :
    CGRect x,y          (x,y)          ,(w,h)       ;    
             ,         (    )            :
 					
     	          :    (anchorPoint);
                                 ,            :
           、     、     、     、       
                 , cocos2d    layer                      ;
          cocos2d layer   (0,0)        ,               layer   ,          layer    ,                      ,   :
    			     
                      :
[cpp] view plaincopy
//---        
CCSprite * spriteOld =[CCSprite spriteWithFile:@"icon.png"];   
[self addChild:spriteOld];  
                              icon      ,           layer     ,   :
    			    
                :
[cpp] view plaincopy
//---            
CCSprite * spriteNew =[CCSprite spriteWithFile:@"icon.png"];  
spriteNew.anchorPoint=ccp(0,0);  
[self addChild:spriteNew];  
                  anchorPoint  ,     CGPoint  , CGPoint  x y   1,       ;
    
      ---------         ,    Himi                           ;
              cocos2d icon        ,              ;    :
       :      ,        x=0(   ),y=0.5(   y   ),    :
[cpp] view plaincopy
//---        
CCSprite * spriteP =[CCSprite spriteWithFile:@"icon.png"];    
spriteP.position=ccp(size.width*0.5,size.height*0.5);//      
spriteP.anchorPoint=ccp(0,0.5);//      
[self addChild:spriteP z:0 tag:88]; //      layer     
                                          , ,            ,                ;
      :              :
[cpp] view plaincopy
@interface HelloWorldLayer : CCLayer  
{  
    float currentShowRect;//           
}  
             :
  
[cpp] view plaincopy
-(id) init  
{  
    [self scheduleUpdate];  
}  
-(void)update:(ccTime)himi{//            
  
}  
   
       :                icon       ,    :
[cpp] view plaincopy
-(void)update:(ccTime)himi{//            
    //         
    CCSprite *sprite =(CCSprite*)[self getChildByTag:88];  
    currentShowRect++;  
    if(currentShowRect>=100){  
        currentShowRect=0;  
    }  
    [sprite setTextureRect:CGRectMake(0, 0, currentShowRect,sprite.position.y)];  
      
}  
          :(icon        ,    )
				
       OK,      ,                 ,         Himi     ,      Himi                      ,   ,         ,        ,       。   ,Himi   ,      ,        ,                      ;
[검은 쌀 Game Dev 블록]에서 원본 링크로 옮겨 싣기:http://www.himigame.com/iphone-cocos2d/501.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
SpriteKit은 게임 점프 캐릭터에 높이 표시기를 추가합니다이것은 점프 낙서와 유사한 작은 게임이다. 주인공이 끊임없이 에너지 공을 먹고 점프 에너지를 얻어 더 높은 곳으로 점프한다. 그림에서 블랙홀에 부딪히면 걸린다. 게임 디버깅 과정에서 주인공의 높이를 실시간으로 알았으...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.