Rev 1524 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package com.gebauz.burutaru.game.entities;
import com.gebauz.bauzoid.math.MathUtil;
import com.gebauz.bauzoid.math.Vector4;
import com.gebauz.burutaru.BurutaruCustomServices;
import com.gebauz.burutaru.GameConsts;
import com.gebauz.burutaru.game.GameLogic;
public class IntroOutroTextDisplay
extends Entity
{
// Constants========================================================================================
public static final float INTRO_FADE_IN = 1.0f
;
public static final float INTRO_WAIT = 2.0f
;
public static final float INTRO_FADE_OUT = 1.0f
;
public static final float INTRO_TOTAL_DURATION = INTRO_FADE_IN + INTRO_WAIT + INTRO_FADE_OUT
;
public static final Vector4 INTRO_TEXT_COLOR =
new Vector4
(1,
1,
1,
1);
// Embedded Types===================================================================================
// Fields===========================================================================================
private float mIntroTimer = 0.0f
;
private boolean mIsIntroStarted =
false;
// Methods==========================================================================================
public IntroOutroTextDisplay
(GameLogic gameLogic
)
{
super(gameLogic
);
}
@
Override
public void initAsync
()
{
}
@
Override
public void init
()
{
}
@
Override
public void exit
()
{
}
@
Override
public void update
(float deltaTime
)
{
if (mIsIntroStarted
)
{
mIntroTimer += deltaTime
;
if (mIntroTimer
> INTRO_TOTAL_DURATION
)
{
mIntroTimer = INTRO_TOTAL_DURATION
;
mIsIntroStarted =
false;
}
}
}
@
Override
public void render
()
{
BurutaruCustomServices s =
(BurutaruCustomServices
)getGame
().
getCustomServices();
if (mIsIntroStarted
)
{
final float scale = 1.0f
;
String text1 =
"Stage 01";
String text2 = getGameLogic
().
getLevel().
getLevelData().
getName();
float w1 = s.
getPrettyFont().
getTextWidth(text1, scale
);
float h1 = s.
getPrettyFont().
getTextHeight(text1, scale
);
float w2 = s.
getPrettyFont().
getTextWidth(text2, scale
);
float h2 = s.
getPrettyFont().
getTextHeight(text2, scale
);
float centerX2 =
(GameConsts.
VIRTUAL_SCREEN_WIDTH - w2
) /
2;
float x2 = -w2
;
float y2 =
(GameConsts.
VIRTUAL_SCREEN_HEIGHT - h2
) /
2 + h2
;
float t2 = MathUtil.
easeInOut(MathUtil.
clamp(mIntroTimer,
0, INTRO_FADE_IN
) / INTRO_FADE_IN
);
x2 += t2
* (centerX2-x2
);
s.
getPrettyFont().
drawText(text1,
30,
30, scale
);
s.
getPrettyFont().
drawText(text2, x2, y2, scale
);
}
}
public void startIntroText
()
{
mIsIntroStarted =
true;
mIntroTimer = 0.0f
;
}
// Getters/Setters==================================================================================
}