当前位置: 首页>>代码示例>>Golang>>正文


Golang gfx.Texture类代码示例

本文整理汇总了Golang中github.com/losinggeneration/hge/gfx.Texture的典型用法代码示例。如果您正苦于以下问题:Golang Texture类的具体用法?Golang Texture怎么用?Golang Texture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Texture类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
	}
}
开发者ID:losinggeneration,项目名称:hge,代码行数:31,代码来源:sprite.go

示例2: New

func New(tex *gfx.Texture, frames int, fps, x, y, w, h float64) Animation {
	var a Animation

	a.Sprite = sprite.New(tex, x, y, w, h)

	a.origWidth = tex.Width(true)

	a.sinceLastFrame = -1.0
	a.speed = 1.0 / fps
	a.frames = frames

	a.mode = FWD | LOOP
	a.delta = 1
	a.SetFrame(0)

	return a
}
开发者ID:losinggeneration,项目名称:hge,代码行数:17,代码来源:animation.go

示例3: 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
}
开发者ID:losinggeneration,项目名称:hge,代码行数:40,代码来源:sprite.go

示例4: SetTexture

func (a *Animation) SetTexture(tex *gfx.Texture) {
	a.Sprite.SetTexture(tex)
	a.origWidth = tex.Width(true)
}
开发者ID:losinggeneration,项目名称:hge,代码行数:4,代码来源:animation.go

示例5: Texture_Unlock

func (h *HGE) Texture_Unlock(tex gfx.Texture) {
	tex.Unlock()
}
开发者ID:losinggeneration,项目名称:hge,代码行数:3,代码来源:hge.go

示例6: Texture_Lock

func (h *HGE) Texture_Lock(tex gfx.Texture, a ...interface{}) *hge.Dword {
	return tex.Lock(a...)
}
开发者ID:losinggeneration,项目名称:hge,代码行数:3,代码来源:hge.go

示例7: Texture_GetHeight

func (h *HGE) Texture_GetHeight(tex gfx.Texture, a ...interface{}) int {
	return tex.Height(a...)
}
开发者ID:losinggeneration,项目名称:hge,代码行数:3,代码来源:hge.go

示例8: Texture_GetWidth

func (h *HGE) Texture_GetWidth(tex gfx.Texture, a ...interface{}) int {
	return tex.Width(a...)
}
开发者ID:losinggeneration,项目名称:hge,代码行数:3,代码来源:hge.go

示例9: Texture_Free

func (h *HGE) Texture_Free(tex *gfx.Texture) {
	tex.Free()
}
开发者ID:losinggeneration,项目名称:hge,代码行数:3,代码来源:hge.go


注:本文中的github.com/losinggeneration/hge/gfx.Texture类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。