當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。