• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang glsprite.Engine函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中golang.org/x/mobile/exp/sprite/glsprite.Engine函数的典型用法代码示例。如果您正苦于以下问题:Golang Engine函数的具体用法?Golang Engine怎么用?Golang Engine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Engine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: onStart

func onStart(glctx gl.Context, u *uistate.UIState) {
	flag.Set("v23.credentials", "/sdcard/credentials")
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), vlog.LogToStderr(true))
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), vlog.Level(0))
	ctx, shutdown := v23.Init()
	u.Shutdown = shutdown
	u.Ctx = ctx
	u.Service = syncbase.NewService(util.MountPoint + "/croupier/" + util.SBName)
	namespace := v23.GetNamespace(u.Ctx)
	allAccess := access.AccessList{In: []security.BlessingPattern{"..."}}
	permissions := access.Permissions{
		"Admin":   allAccess,
		"Write":   allAccess,
		"Read":    allAccess,
		"Resolve": allAccess,
		"Debug":   allAccess,
	}
	namespace.SetPermissions(u.Ctx, util.MountPoint, permissions, "")
	namespace.SetPermissions(u.Ctx, util.MountPoint+"/croupier", permissions, "")
	u.Service.SetPermissions(u.Ctx, permissions, "")
	u.Images = glutil.NewImages(glctx)
	fps = debug.NewFPS(u.Images)
	u.Eng = glsprite.Engine(u.Images)
	u.Texs = texture.LoadTextures(u.Eng)
	u.CurTable = table.InitializeGame(u.NumPlayers, u.Texs)
	sound.InitPlayers(u)
	sync.CreateTables(u)
	// Create watch stream to update game state based on Syncbase updates
	go sync.UpdateSettings(u)
}
开发者ID:vanadium,项目名称:croupier,代码行数:30,代码来源:main.go


示例2: TestThree

// Testing full image adjustment after screen resizing (assumes adjustImgs is scaling dimensions)
func TestThree(test *testing.T) {
	u = uistate.MakeUIState()
	u.Scene = &sprite.Node{}
	u.Eng = glsprite.Engine(nil)
	u.Eng.Register(u.Scene)
	u.Eng.SetTransform(u.Scene, f32.Affine{
		{1, 0, 0},
		{0, 1, 0},
	})
	imgPos := coords.MakeVec(5, 20)
	imgDimensions := coords.MakeVec(10, 10)
	newButton := texture.MakeImgWithoutAlt(subtex, imgPos, imgDimensions, u)
	u.Buttons["1"] = newButton
	oldWindow := u.WindowSize.DividedBy(2)
	resize.AdjustImgs(oldWindow, u)
	newPos := u.Buttons["1"].GetCurrent()
	newDimensions := u.Buttons["1"].GetDimensions()
	dimExpect := imgDimensions.Times(2)
	posExpect := imgPos.Times(2)
	if newDimensions.X != dimExpect.X {
		test.Errorf("Expected width %f, got %f", dimExpect.X, newDimensions.X)
	}
	if newDimensions.Y != dimExpect.Y {
		test.Errorf("Expected height %f, got %f", dimExpect.Y, newDimensions.Y)
	}
	if newPos.X != posExpect.X {
		test.Errorf("Expected x %f, got %f", posExpect.X, newPos.X)
	}
	if newPos.Y != posExpect.Y {
		test.Errorf("Expected y %f, got %f", posExpect.Y, newPos.Y)
	}
}
开发者ID:vanadium,项目名称:croupier,代码行数:33,代码来源:img_test.go


示例3: main

func main() {
	app.Main(func(a app.App) {
		var c event.Config
		var eng *WritableEngine
		var root *sprite.Node
		startClock := time.Now()
		for e := range a.Events() {
			switch e := event.Filter(e).(type) {
			case event.Config:
				c = e
			case event.Draw:
				if eng == nil || root == nil {
					eng = NewWritableEngine(
						glsprite.Engine(),
						image.Rect(0, 0, int(c.Width.Px(c.PixelsPerPt)), int(c.Height.Px(c.PixelsPerPt))),
						color.White,
					)
					root = loadScene(eng, loadTextures(eng))
					go listen(eng, ":8080")
				}
				now := clock.Time(time.Since(startClock) * 60 / time.Second)
				gl.ClearColor(1, 1, 1, 1)
				gl.Clear(gl.COLOR_BUFFER_BIT)
				gl.Enable(gl.BLEND)
				gl.BlendEquation(gl.FUNC_ADD)
				gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
				if eng != nil && root != nil {
					eng.Render(root, now, c)
				}
				a.EndDraw()
			}
		}
	})
}
开发者ID:golang-samples,项目名称:gomobile,代码行数:34,代码来源:main.go


示例4: TestFive

// Testing NewImgWithAlt
func TestFive(test *testing.T) {
	scene := &sprite.Node{}
	eng := glsprite.Engine(nil)
	u.Eng = eng
	u.Scene = scene
	pos := coords.MakeVec(5, 10)
	dimensions := coords.MakeVec(20, 10)
	i := texture.MakeImgWithAlt(subtex, subtex, pos, dimensions, true, u)
	if i.GetCurrent().X != pos.X {
		test.Errorf("Expected x %f, got %f", pos.X, i.GetCurrent().X)
	}
	if i.GetCurrent().Y != pos.Y {
		test.Errorf("Expected y %f, got %f", pos.Y, i.GetCurrent().Y)
	}
	if i.GetInitial().X != pos.X {
		test.Errorf("Expected inital x %f, got %f", pos.X, i.GetInitial().X)
	}
	if i.GetInitial().Y != pos.Y {
		test.Errorf("Expected initial y %f, got %f", pos.Y, i.GetInitial().Y)
	}
	if i.GetDimensions().X != dimensions.X {
		test.Errorf("Expected width %f, got %f", dimensions.X, i.GetDimensions().X)
	}
	if i.GetDimensions().Y != dimensions.Y {
		test.Errorf("Expected height %f, got %f", dimensions.Y, i.GetDimensions().Y)
	}
}
开发者ID:vanadium,项目名称:croupier,代码行数:28,代码来源:img_test.go


示例5: onStart

func onStart(glctx gl.Context, sz size.Event) {
	images = glutil.NewImages(glctx)
	eng = glsprite.Engine(images)
	log = gmlog.New(images, 5)
	bbot = NewApp()
	bbot.Reset(sz)
	scene = bbot.Scene(eng, sz)
}
开发者ID:viru,项目名称:berrybot,代码行数:8,代码来源:main.go


示例6: TestSix

// Testing resetting card position
func TestSix(test *testing.T) {
	u = uistate.MakeUIState()
	u.Scene = &sprite.Node{}
	u.Eng = glsprite.Engine(nil)
	u.Eng.Register(u.Scene)
	u.Eng.SetTransform(u.Scene, f32.Affine{
		{1, 0, 0},
		{0, 1, 0},
	})
	u.EmptySuitImgs = []*staticimg.StaticImg{staticimg.MakeStaticImg(), staticimg.MakeStaticImg(), staticimg.MakeStaticImg(), staticimg.MakeStaticImg()}
	u.WindowSize = windowSize
	n := texture.MakeNode(u)
	for _, e := range u.EmptySuitImgs {
		e.SetImage(subtex)
		e.SetAlt(subtex)
		e.SetNode(n)
	}
	c := card.NewCard(card.Two, card.Heart)
	c2 := card.NewCard(card.Four, card.Heart)
	n = texture.MakeNode(u)
	n2 := texture.MakeNode(u)
	initialXY := coords.MakeVec(10, 10)
	curXY := coords.MakeVec(100, 30)
	dimensions := coords.MakeVec(5, 5)
	c.SetNode(n)
	c2.SetNode(n2)
	c.SetInitial(initialXY)
	c2.SetInitial(initialXY)
	c.Move(curXY, dimensions, u.Eng)
	c2.Move(curXY, dimensions, u.Eng)
	u.Cards = append(u.Cards, c)
	u.Cards = append(u.Cards, c2)
	if c.GetCurrent().X != curXY.X {
		test.Errorf("Expected x %f, got %f", curXY.X, c.GetCurrent().X)
	}
	if c.GetCurrent().Y != curXY.Y {
		test.Errorf("Expected y %f, got %f", curXY.Y, c.GetCurrent().Y)
	}
	reposition.ResetCardPosition(c, u.Eng)
	reposition.ResetCardPosition(c2, u.Eng)
	reposition.RealignSuit(c.GetSuit(), c.GetInitial().Y, u)
	if c.GetCurrent().X != u.Padding {
		test.Errorf("Expected x %f, got %f", initialXY.X, c.GetCurrent().X)
	}
	if c.GetCurrent().Y != initialXY.Y {
		test.Errorf("Expected y %f, got %f", initialXY.Y, c.GetCurrent().Y)
	}
	if c2.GetCurrent().X != u.Padding+dimensions.X+u.Padding {
		test.Errorf("Expected x %f, got %f", u.Padding+dimensions.X+u.Padding, c2.GetCurrent().X)
	}
	if c2.GetCurrent().Y != initialXY.Y {
		test.Errorf("Expected y %f, got %f", initialXY.Y, c2.GetCurrent().Y)
	}
}
开发者ID:vanadium,项目名称:croupier,代码行数:55,代码来源:img_test.go


示例7: initEng

func (self *GLPeer) initEng() {
	if self.eng != nil {
		self.eng.Release()
	}
	self.eng = glsprite.Engine(self.images)
	self.scene = &sprite.Node{}
	self.eng.Register(self.scene)
	self.eng.SetTransform(self.scene, f32.Affine{
		{1, 0, 0},
		{0, 1, 0},
	})
}
开发者ID:sassy,项目名称:gomo-simra,代码行数:12,代码来源:peer.go


示例8: onPaint

func onPaint(sz size.Event) {
	if scene == nil {
		images = glutil.NewImages()
		fps = debug.NewFPS(images)
		eng = glsprite.Engine(images)
		loadScene()
	}
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)
	eng.Render(scene, now, sz)
	fps.Draw(sz)
}
开发者ID:samanalysis,项目名称:mobile,代码行数:13,代码来源:main.go


示例9: onStart

func onStart(glctx gl.Context) {
	images = glutil.NewImages(glctx)
	eng = glsprite.Engine(images)
	loadScene()

	rc, err := asset.Open("boing.wav")
	if err != nil {
		log.Fatal(err)
	}
	player, err = audio.NewPlayer(rc, 0, 0)
	if err != nil {
		log.Fatal(err)
	}
}
开发者ID:0x90sled,项目名称:mobile,代码行数:14,代码来源:main.go


示例10: loadScene

func loadScene(sceneId int) {
	if eng != nil {
		eng.Release()
	}
	eng = glsprite.Engine(images)
	scene = &sprite.Node{}
	eng.Register(scene)
	eng.SetTransform(scene, f32.Affine{
		{1, 0, 0},
		{0, 1, 0},
	})

	switch sceneId {
	case 0:
		// load Gopher
		Title.Move(screenSizeX/2, screenSizeY/2)
		Title.width = screenSizeX
		Title.height = screenSizeY
		Title.radian = 0
		tex_title := loadTextures("title.png", image.Rect(0, 0, int(screenSizeX), int(screenSizeY)))
		Title.node = newNode()
		eng.SetSubTex(Title.node, tex_title)
		Title.Apply()

	case 1:
		// load Gopher
		Gopher.Move(screenSizeX/2, screenSizeY/2)
		Gopher.width = spriteSizeX
		Gopher.height = spriteSizeY
		Gopher.radian = 0
		tex_gopher := loadTextures("waza-gophers.jpeg", image.Rect(152, 10, 152+int(Gopher.width), 10+int(Gopher.height)))
		Gopher.node = newNode()
		eng.SetSubTex(Gopher.node, tex_gopher)
		Gopher.Apply()

		// load Ball
		Ball.Move(screenSizeX/3, screenSizeY/3)
		Ball.width = 48
		Ball.height = 48
		Ball.radian = 0
		tex_ball := loadTextures("ball.png", image.Rect(0, 0, int(Ball.width), int(Ball.height)))
		Ball.node = newNode()
		eng.SetSubTex(Ball.node, tex_ball)
		Ball.Apply()
	}
}
开发者ID:pankona,项目名称:gomobile_sprite_test,代码行数:46,代码来源:main.go


示例11: NewEngine

func NewEngine(screenWidth, screenHeight int) *Engine {
	e := new(Engine)
	e.screenWidth = screenWidth
	e.screenHeight = screenHeight
	e.startTime = time.Now()
	e.eng = glsprite.Engine()
	e.scene = &s.Node{}

	e.eng.Register(e.scene)
	e.eng.SetTransform(e.scene, f32.Affine{
		{1, 0, 0},
		{0, 1, 0},
	})
	e.arranger = new(arrangerFunc)
	e.arranger.eng = e
	e.sprites = make(map[*s.Node]*Sprite)
	return e
}
开发者ID:mccordnate,项目名称:gogam,代码行数:18,代码来源:engine.go


示例12: main

	"github.com/acsellers/ofs/game"
	"golang.org/x/mobile/app"
	"golang.org/x/mobile/asset"
	"golang.org/x/mobile/event/paint"
	"golang.org/x/mobile/event/size"
	"golang.org/x/mobile/exp/app/debug"
	"golang.org/x/mobile/exp/f32"
	"golang.org/x/mobile/exp/sprite"
	"golang.org/x/mobile/exp/sprite/clock"
	"golang.org/x/mobile/exp/sprite/glsprite"
	"golang.org/x/mobile/gl"
)

var (
	v     game.Vault
	eng   = glsprite.Engine()
	scene *sprite.Node
	start = time.Now()
	dbg   = flag.Bool("debug", false, "Turn on debug mode")
)

func main() {
	flag.Parse()

	v = game.NewVault()
	v.PlaceRoom(9, 0, 1)
	v.PlaceRoom(9, 1, 1)
	v.PlaceRoom(10, 1, 2)

	// setup transparency for sprites
	gl.Disable(gl.DEPTH_TEST)
开发者ID:acsellers,项目名称:ofs,代码行数:31,代码来源:main.go


示例13: onStart

// 開始時点で呼ばれる関数なので、Sprite Engineを初期化する
func onStart(glctx gl.Context) {
	images = glutil.NewImages(glctx) //OpenGLのContextからImageオブジェクトを生成
	eng = glsprite.Engine(images)    // Engineオブジェクトを生成する
	game = NewGame()
	scene = game.Scene(eng)
}
开发者ID:toohsk,项目名称:gomobile-study,代码行数:7,代码来源:main.go


示例14: onStart

func onStart(glctx gl.Context) {
	images = glutil.NewImages(glctx)
	fps = debug.NewFPS(images)
	eng = glsprite.Engine(images)
	loadScene()
}
开发者ID:arnold8,项目名称:mobile,代码行数:6,代码来源:main.go


示例15: onStart

func onStart(glctx gl.Context) {
	images = glutil.NewImages(glctx)
	eng = glsprite.Engine(images)
	game = NewGame()
	scene = game.Scene(eng)
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:6,代码来源:main.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang geom.Pt函数代码示例发布时间:2022-05-28
下一篇:
Golang clock.Time函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap