Rev 124 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package com.gebauz.pingK.common.game;
import com.gebauz.pingK.common.game.MultitouchInput.Finger;
public class TextButton
extends BaseButton
{
private Font mFont =
null;
private String mText
;
public TextButton
(Font font,
String text
)
{
mFont = font
;
mText = text
;
}
@
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 =
Font.
CHARACTER_SIZE * scale
;
mFont.
drawText("=" + mText +
"=", getTopLeftX
() - offsetX, getTopLeftY
(), scale
);
}
else
{
mFont.
drawText(mText, getTopLeftX
(), getTopLeftY
(), scale
);
}
}
}
public void setText
(String text
)
{
mText = text
;
}
public String getText
()
{
return mText
;
}
@
Override
public float getWidth
()
{
return ((float)mText.
length() * (float)Font.
CHARACTER_SIZE * scale
);
}
@
Override
public float getHeight
()
{
return ((float)Font.
CHARACTER_SIZE * scale
);
}
}