本文整理汇总了Golang中github.com/paked/engi.Entity类的典型用法代码示例。如果您正苦于以下问题:Golang Entity类的具体用法?Golang Entity怎么用?Golang Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Update
func (fs *FallingSystem) Update(entity *engi.Entity, dt float32) {
var space *engi.SpaceComponent
if !entity.Component(&space) {
return
}
space.Position.Y += 200 * dt
}
示例2: Update
func (c *ControlSystem) Update(entity *engi.Entity, dt float32) {
//Check scheme
// -Move entity based on that
var control *ControlComponent
var space *engi.SpaceComponent
if !entity.Component(&space) || !entity.Component(&control) {
return
}
up := false
down := false
if control.Scheme == "WASD" {
up = engi.Keys.Get(engi.W).Down()
down = engi.Keys.Get(engi.S).Down()
} else {
up = engi.Keys.Get(engi.ArrowUp).Down()
down = engi.Keys.Get(engi.ArrowDown).Down()
}
if up {
space.Position.Y -= 800 * dt
}
if down {
space.Position.Y += 800 * dt
}
}
示例3: Update
func (c *HideSystem) Update(e *engi.Entity, dt float32) {
var render *engi.RenderComponent
if !e.Component(&render) {
return
}
if rand.Int()%10 == 0 {
render.SetPriority(engi.Hidden)
} else {
render.SetPriority(engi.MiddleGround)
}
}
示例4: Update
func (c *ControlSystem) Update(entity *engi.Entity, dt float32) {
var a *engi.AnimationComponent
if !entity.Component(&a) {
return
}
if engi.Keys.Get(engi.ArrowRight).Down() {
a.SelectAnimationByAction(WalkAction)
} else if engi.Keys.Get(engi.Space).Down() {
a.SelectAnimationByAction(SkillAction)
} else {
a.SelectAnimationByAction(StopAction)
}
}
示例5: Update
func (c *ScaleSystem) Update(e *engi.Entity, dt float32) {
var render *engi.RenderComponent
if !e.Component(&render) {
return
}
var mod float32
if rand.Int()%2 == 0 {
mod = 0.1
} else {
mod = -0.1
}
if render.Scale.X+mod >= 15 || render.Scale.X+mod <= 1 {
mod *= -1
}
render.Scale.AddScalar(mod)
}