cocos2d for android - CCLabelAtlas 색 주기

/**
    * FileName : AtlasTest.java
    * Comment : 비트맵을 이용한 텍스트
    * @version : 1.0
    * @author : coolsharp
    * @date : 2011. 10. 19.
    */
    static class LabelAtlasColorTest extends AtlasDemo {
        float time;
 
        /**
         * 색상을 줄 수 있다.
         */
        public LabelAtlasColorTest() {
            super();
 
            CCLabelAtlas label1 = CCLabelAtlas.label("123 Test", 
                    "tuffy_bold_italic-charmap.png", 48, 64, ' ');
            addChild(label1, 0, kTagSprite1);
            label1.setPosition(CGPoint.ccp(10,100));
            label1.setOpacity(200);
 
            CCLabelAtlas label2 = CCLabelAtlas.label("0123456789", 
                    "tuffy_bold_italic-charmap.png", 48, 64, ' ');
            addChild(label2, 0, kTagSprite2);
            label2.setPosition(CGPoint.ccp(10,200));
            // 이곳이 바로 키 포인트 빨간 색
            label2.setColor(ccColor3B.ccRED);
 
            CCFadeOut fade = CCFadeOut.action(1.0f);
            CCFadeIn fade_in = fade.reverse();
            CCSequence seq = CCSequence.actions(fade, fade_in);
            CCRepeatForever repeat = CCRepeatForever.action(seq);
            label2.runAction(repeat);
 
            schedule(new UpdateCallback() {
                
                @Override
                public void update(float d) {
                    step(d);
                }
            });
        }
 
        public void step(float dt) {
            time += dt;
            String string = CCFormatter.format("%2.2f Test", time);
            CCLabelAtlas label1 = (CCLabelAtlas) getChildByTag(kTagSprite1);
            label1.setString(string);
 
            CCLabelAtlas label2 = (CCLabelAtlas) getChildByTag(kTagSprite2);
            label2.setString(CCFormatter.format("%d", (int)time));    
        }
 
        public String title() {
            return "CCLabelAtlas LabelAtlasColorTest";
        }
 
        public String subtitle() {
            return "Opacity + Color should work at the same time";
        }
    }

댓글

이 블로그의 인기 게시물

ViewPager offscreenPageLimit 메모리 상태

ASP에서 C# 언어로 만든 DLL 호출

eskimo esim 사용기 - 일본 / 오사카(23/08/06 ~ 23/08/08)