代码拉取完成,页面将自动刷新
package Sarah
import "github.com/faiface/pixel"
func CreateAnimation() *Animation {
a := new(Animation)
a.Index = 0.0
a.Time = 0.0
return a
}
type Animation struct {
Sprites []*Sprite
Index float64//图组索引
Time float64//运行的时长
pos pixel.Vec//位置
}
func (this *Animation) SetPos(x float64,y float64){
this.pos.X=x
this.pos.Y=y
for _,v := range this.Sprites{
v.pos = pixel.Vec{this.pos.X,this.pos.Y}
}
}
func (this *Animation) GetPos()(float64,float64){
return this.pos.X,this.pos.Y
}
func (this *Animation) AddPic(path string){
pic,err := LoadPicture_l(path)
CheckError(err)
s := CreatSprite(path)
s.Sprite = pixel.NewSprite(pic,pic.Bounds())
s.pos = this.pos
this.Sprites = append(this.Sprites,s)
}
func (this *Animation) set_index(){
if int(this.Index) == len(this.Sprites)-1 {
this.Index = 0.0
}else {
this.Index+=0.2
}
}
func (this *Animation) Play(scene *SceneManager){
this.set_index()
this.Sprites[int(this.Index)].Draw(scene,1)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。