Rev 315 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package com.gebauz.pingk.ui;
import com.gebauz.Bauzoid.app.Game;
import com.gebauz.pingk.game.GameConsts;
public class TextButton
extends BaseButton
{
private String mText
;
public TextButton
(Game game,
String text
)
{
super(game
);
mText = text
;
}
@
Override
public void init
()
{
}
@
Override
public void exit
()
{
}
@
Override
public void update
(float deltaTime
)
{
super.
update(deltaTime
);
}
@
Override
public void render
()
{
super.
render();
if (mText.
length() > 0)
{
if ((mTouchListener
!=
null) && isPushed
())
//if (isCurrentlyTouched())
{
float offsetX = getFont
().
getTextWidth("=", scale
);
getFont
().
drawText("=" + mText +
"=", getTopLeftX
() - offsetX, getTopLeftY
(), GameConsts.
PINGK_COLOR, scale
);
}
else
{
getFont
().
drawText(mText, getTopLeftX
(), getTopLeftY
(), GameConsts.
PINGK_COLOR, scale
);
}
}
}
public void setText
(String text
)
{
mText = text
;
}
public String getText
()
{
return mText
;
}
public float getWidth
()
{
return getFont
().
getTextWidth(mText, scale
);
}
public float getHeight
()
{
return getFont
().
getTextHeight(mText, scale
);
}
}