/*
* Use any of these editors to generate bitmap font atlas:
* http://www.n4te.com/hiero/hiero.jnlp
* http://slick.cokeandcode.com/demos/hiero.jnlp
* http://www.angelcode.com/products/bmfont/
*/
/**
* FileName : AtlasTest.java
* Comment : 비트맵 폰트에 효과주기
* @version : 1.0
* @author : coolsharp
* @date : 2011. 10. 19.
*/
static class Atlas4 extends AtlasDemo {
float time;
public Atlas4() {
super();
// Upper Label
CCBitmapFontAtlas label = CCBitmapFontAtlas.bitmapFontAtlas("Bitmap Font Atlas", "bitmapFontTest.fnt");
addChild(label);
CGSize s = CCDirector.sharedDirector().winSize();
label.setPosition(CGPoint.ccp(s.width/2, s.height/2));
label.setAnchorPoint(CGPoint.ccp(0.5f, 0.5f));
// label의 첫번째 글자를 얻어옴
CCSprite BChar = (CCSprite) label.getChildByTag(0);
// label의 7번재 글자를 얻어옴
CCSprite FChar = (CCSprite) label.getChildByTag(7);
// label의 12번째 글자를 얻어옴
CCSprite AChar = (CCSprite) label.getChildByTag(12);
// 회전 효과 생성
CCRotateBy rotate = CCRotateBy.action(2, 360);
CCRepeatForever rot_4ever = CCRepeatForever.action(rotate);
// 크기 조절 효과 생성
CCScaleBy scale = CCScaleBy.action(2, 1.5f);
CCScaleBy scale_back = scale.reverse();
CCSequence scale_seq = CCSequence.actions(scale, scale_back);
CCRepeatForever scale_4ever = CCRepeatForever.action(scale_seq);
// 통통 뛰기 효과 생성
CCJumpBy jump = CCJumpBy.action(0.5f, CGPoint.zero(), 60, 1);
CCRepeatForever jump_4ever = CCRepeatForever.action(jump);
CCFadeOut fade_out = CCFadeOut.action(1);
CCFadeIn fade_in = CCFadeIn.action(1);
CCSequence seq = CCSequence.actions(fade_out, fade_in);
CCRepeatForever fade_4ever = CCRepeatForever.action(seq);
BChar.runAction(rot_4ever);
BChar.runAction(scale_4ever);
FChar.runAction(jump_4ever);
AChar.runAction(fade_4ever);
// Bottom Label
CCBitmapFontAtlas label2 = CCBitmapFontAtlas.bitmapFontAtlas("00.0", "bitmapFontTest.fnt");
addChild(label2, 0, kTagBitmapAtlas2);
label2.setPosition(CGPoint.ccp(s.width/2.0f, 80));
CCSprite lastChar = (CCSprite)label2.getChildByTag(3);
lastChar.runAction(rot_4ever.copy());
schedule(new UpdateCallback() {
@Override
public void update(float d) {
step(d);
}
}, 0.1f);
}
public void draw(GL10 gl) {
CGSize s = CCDirector.sharedDirector().winSize();
CCDrawingPrimitives.ccDrawLine(gl, CGPoint.ccp(0, s.height/2), CGPoint.ccp(s.width, s.height/2) );
CCDrawingPrimitives.ccDrawLine(gl, CGPoint.ccp(s.width/2, 0), CGPoint.ccp(s.width/2, s.height) );
}
public void step(float dt) {
time += dt;
String string = CCFormatter.format("%04.1f", time);
CCBitmapFontAtlas label1 = (CCBitmapFontAtlas) getChildByTag(kTagBitmapAtlas2);
label1.setString(string);
}
@Override
public String title() {
return "CCBitmapFontAtlas Atlas4";
}
public String subtitle() {
return "Using fonts as CCSprite objects. Some characters should rotate.";
}
}
댓글
댓글 쓰기