2012年5月27日 星期日

Java & Slick 遊戲開發(7)-Shapes, Text, and Titles!


在Menu.class的Render function:

public void render(GameContainer gc,StateBasedGame sbg, Graphics g) throws SlickException
{
g.drawString("Are you ready to blast some ham!", 50, 50); //string,x,y
g.drawRect(50, 100, 60, 120); //x,y,width,height
g.drawOval(200, 130, 130, 80); //x,y,width,height
}

render類似draw:
.drawString --> 畫出字串
.drawRect --> 畫出長方形
.drawOval --> 畫出隋圓形

Run this program,出現如下圖:


沒有留言:

張貼留言