コード例 #1
0
ファイル: PowerUp.go プロジェクト: gulinfang/GarageEngine
func (pu *PowerUp) OnCollisionEnter(arbiter engine.Arbiter) bool {
	if pu.GameObject() != nil && (arbiter.GameObjectA() == Player || arbiter.GameObjectB() == Player) {
		PowerUpShip(pu.Type)
		pu.GameObject().Destroy()
	}
	return true
}
コード例 #2
0
ファイル: Enemy.go プロジェクト: banad/PirateLand
func (s *Enemy) OnCollisionPostSolve(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() != nil {
		if arbiter.GameObjectB().Tag != "lader" && arbiter.GameObjectA().Tag != "lader" {
			count := 0
			for _, con := range arbiter.Contacts {
				if arbiter.Normal(con).Y < -0.9 {
					count++

				}
			}
			if count >= 1 {
				if s.GameObject().Sprite.CurrentAnimation() == "enemy_jump" {
					s.GameObject().Sprite.SetAnimation("enemy_stand")
				}
				s.LastFloor = arbiter.GameObjectB()

				s.OnGround = true
			}
			count = 0
			for _, con := range arbiter.Contacts {
				if math.Abs(float64(arbiter.Normal(con).X)) > 0.9 {
					count++

				}
			}
			if count >= 1 {
				s.jump = true
			}
			if arbiter.GameObjectB().Tag == "player" {
				if Player.PlComp.Hitable && s.Attack {
					Player.PlComp.Hit()
				}
				if s.hitable && Player.PlComp.Attack {
					s.Hit()
				}
			}
		}
	}

}
コード例 #3
0
ファイル: player.go プロジェクト: banad/PirateLand
func (pl *Player) OnCollisionPostSolve(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() == nil {
		return
	}
	if arbiter.GameObjectB().Tag != "lader" && arbiter.GameObjectA().Tag != "lader" {
		count := 0
		for _, con := range arbiter.Contacts {
			if arbiter.Normal(con).Y < -0.9 {
				count++

			}
		}
		if count >= 1 {
			if pl.GameObject().Sprite.CurrentAnimation() == "player_jump" {
				pl.GameObject().Sprite.SetAnimation("player_stand")
			}
			pl.LastFloor = arbiter.GameObjectB()

			pl.OnGround = true
		}
	}

}