cocos2d for andorid - CCLabelAtlas

/**
* FileName : AtlasTest.java
* Comment : 비트맵 폰트
* @version : 1.0
* @author : coolsharp
* @date : 2011. 10. 19.
*/
static class LabelAtlasTest extends AtlasDemo {
    float time;
 
    /**
     * Constructor
     */
    public LabelAtlasTest() {
        super();
        
        // 123 Test라는 기본 텍스트에 tuffy_bold_italic-charmap_s.png라는 비트맵 폰트 파일을 대입한 라벨 생성함
        // 폰트당 크기는 넓이 48, 높이 64
        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.setOpacity(32);
 
        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 Time", (int)time));
    }
 
    @Override
    public String title() {
        return "CCLabelAtlas LabelAtlasTest";
    }
 
    public String subtitle() {
        return "Updating label should be fast";
    }
}

댓글

이 블로그의 인기 게시물

ViewPager offscreenPageLimit 메모리 상태

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

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