代码拉取完成,页面将自动刷新
package Sarah
import (
"github.com/faiface/pixel"
)
func MakeButton(x float64,y float64,str string)*Button {
return &Button{Pos: pixel.Vec{X: x,Y: y},Text: CreatText(x,y,str)}
}
type Button struct {
Width float64//宽
Height float64//高
Pos pixel.Vec//坐标
Bg_pic *pixel.Sprite//背景图
Text *Text//文字
Scale_status bool//缩放状态
}
func (this *Button) SetSize(width float64,height float64){
this.Width = width
this.Height = height
}
func (this *Button) SetPos(x float64,y float64){
this.Pos = pixel.Vec{X: x,Y: y}
}
//设置文字
func (this *Button) SetText(str string){
this.Text.str = str
}
func (this *Button)Draw(scene *SceneManager){
this.Scale()
//画一个矩形
imd := DrawRect(this.Pos,this.Width,this.Height)
imd.Draw(scene.Window)
//画出文字
this.Text.Draw(scene,1,this.Pos.X,this.Pos.Y)
}
//缩放
func (this *Button) Scale(){
if this.Scale_status == false{
this.Height = 50
this.Width = 100
}else{
this.Height = 75
this.Width = 200
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。