本文整理汇总了Golang中github.com/losinggeneration/hge/gfx.Texture.Height方法的典型用法代码示例。如果您正苦于以下问题:Golang Texture.Height方法的具体用法?Golang Texture.Height怎么用?Golang Texture.Height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/losinggeneration/hge/gfx.Texture
的用法示例。
在下文中一共展示了Texture.Height方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetTexture
func (sprite *Sprite) SetTexture(tex *gfx.Texture) {
var tw, th float64
sprite.Quad.Texture = tex
if tex != nil {
tw = float64(tex.Width())
th = float64(tex.Height())
} else {
tw, th = 1.0, 1.0
}
if tw != sprite.TexW || th != sprite.TexH {
tx1 := float64(sprite.Quad.V[0].TX) * sprite.TexW
ty1 := float64(sprite.Quad.V[0].TY) * sprite.TexH
tx2 := float64(sprite.Quad.V[2].TX) * sprite.TexW
ty2 := float64(sprite.Quad.V[2].TY) * sprite.TexH
sprite.TexW, sprite.TexH = tw, th
tx1 /= tw
ty1 /= th
tx2 /= tw
ty2 /= th
sprite.Quad.V[0].TX, sprite.Quad.V[0].TY = float32(tx1), float32(ty1)
sprite.Quad.V[1].TX, sprite.Quad.V[1].TY = float32(tx2), float32(ty1)
sprite.Quad.V[2].TX, sprite.Quad.V[2].TY = float32(tx2), float32(ty2)
sprite.Quad.V[3].TX, sprite.Quad.V[3].TY = float32(tx1), float32(ty2)
}
}
示例2: New
func New(texture *gfx.Texture, texx, texy, w, h float64) Sprite {
var sprite Sprite
sprite.TX, sprite.TY = texx, texy
sprite.W, sprite.H = w, h
if texture != nil {
sprite.TexW = float64(texture.Width())
sprite.TexH = float64(texture.Height())
} else {
sprite.TexW = 1.0
sprite.TexH = 1.0
}
sprite.Quad.Texture = texture
texx1 := texx / sprite.TexW
texy1 := texy / sprite.TexH
texx2 := (texx + w) / sprite.TexW
texy2 := (texy + h) / sprite.TexH
sprite.Quad.V[0].TX, sprite.Quad.V[0].TY = float32(texx1), float32(texy1)
sprite.Quad.V[1].TX, sprite.Quad.V[1].TY = float32(texx2), float32(texy1)
sprite.Quad.V[2].TX, sprite.Quad.V[2].TY = float32(texx2), float32(texy2)
sprite.Quad.V[3].TX, sprite.Quad.V[3].TY = float32(texx1), float32(texy2)
sprite.Quad.V[0].Z = 0.5
sprite.Quad.V[1].Z = 0.5
sprite.Quad.V[2].Z = 0.5
sprite.Quad.V[3].Z = 0.5
sprite.Quad.V[0].Color = 0xffffffff
sprite.Quad.V[1].Color = 0xffffffff
sprite.Quad.V[2].Color = 0xffffffff
sprite.Quad.V[3].Color = 0xffffffff
sprite.Quad.Blend = gfx.BLEND_DEFAULT
return sprite
}
示例3: Texture_GetHeight
func (h *HGE) Texture_GetHeight(tex gfx.Texture, a ...interface{}) int {
return tex.Height(a...)
}