當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Texture.Query方法代碼示例

本文整理匯總了Golang中github.com/veandco/go-sdl2/sdl.Texture.Query方法的典型用法代碼示例。如果您正苦於以下問題:Golang Texture.Query方法的具體用法?Golang Texture.Query怎麽用?Golang Texture.Query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/veandco/go-sdl2/sdl.Texture的用法示例。


在下文中一共展示了Texture.Query方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: draw_texture

func (t *Text) draw_texture(texture *sdl.Texture, x, y int32, center_x, center_y bool) {
	_, _, t.w, t.h, _ = texture.Query()
	if center_x {
		x = int32(win_size/2 - t.w/2)
	}
	if center_y {
		y = int32(win_size/2 - t.h/2)
	}
	dst = sdl.Rect{x, y, int32(t.w), int32(t.h)}
	renderer.Copy(texture, &src, &dst)
}
開發者ID:queyenth,項目名稱:QuestionMarkGame,代碼行數:11,代碼來源:main.go

示例2: GetSizeOfGraphic

// GetSizeOfGraphic returns the width and heigth of the Graphic, g.
// GetSizeOfGraphic returns two numbers of type int. The first numnber,
// marked as 'width', is the width of the Graphic, g, in pixels. The second number,
// marked as 'height' is the height of the Graphic, g, in pixels.
//
// GetSizeOfGraphic will panic if:
//
// 1. The Graphic, g, does not contain a Graphic type.
//
// 2. The toolbox has not been initialised.
func GetSizeOfGraphic(g Graphic) (width, height int) {
	if !initialised {
		// this stops execution here, so ne need for an else after the if
		panic(notInitialisedMessage)
	}
	if g == nil {
		panic(nilGraphicMessage)
	}
	var w, h int32
	var err error
	var t *sdl.Texture
	t = g
	_, _, w, h, err = t.Query()
	if err != nil {
		fmt.Print("Failed to query texture: ")
		fmt.Println(err)
		panic(err)
	}
	width = int(w)
	height = int(h)
	// return is implicit - using named return paramaters
	return
}
開發者ID:gophercoders,項目名稱:toolbox,代碼行數:33,代碼來源:toolbox.go


注:本文中的github.com/veandco/go-sdl2/sdl.Texture.Query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。