如何让我的敌人走上一条道路?这就是我现在所拥有的一切,我正在使用Tiled作为图像等。我正在尝试制作一个玩家进入某个区域的游戏,并且必须避开敌人才能获得硬币,这样门才会打开到下一个区域。但是因为我的敌人正在巡逻敌人,有时会进入下一个区域的走廊,这显然不应该发生。
我的门也有问题,当我拿起硬币时它不会消失。我认为最简单的方法是,当我达到一定分数时,门被移除,但在玩家接触门之前它不会消失。有什么建议?也许将硬币与门连接起来,这样当它被拾起时,它们都会以某种方式消失?
Level.Load ("Game.tmx")
player = {
object = nil,
score = 0,
health = 100,
speed = 3,
}
function Start()
--Identify the objects, naming them
player.object = Level.GetObject ("Player")
enemy = Level.GetObject ("Enemy")
-- music = Sound.Load ("music.mp3", true, true)
Hud.Message ( " Start ", 2)
end
function DoPlayer()
player.object = Level.GetObject( "Player")
end
function DoEnemey()
enemy = Level.GetObjects( "Enemey" )
end
function DoSign()
Sign = Level.GetObject( "Sign" )
end
function DoDoor()
door = Level.GetObject( "door" )
end
function Update()
--HUD
Hud.Score ("Score : " ..player.score )
Hud.Health ("Health : " ..player.health )
--Controllers
Controller.Wasd (player.object, player.speed)
Controller.Patrol (enemy, 2)
Camera.Follow (player.object)
end
function info()
Hud.Message ("Pick up coins to proceed to the next area!", 3)
end
function CoinPickup( target, source)
if target == player.object then
player.score = player.score + 1
Level.RemoveObject( source )
end
end
function DoorOpen( target, source)
if target == player.object
and player.score == 2
then Level.RemoveObject ( source )
end
end