游戏开发:攻击按钮连接与相机及参考节点运用
攻击按钮连接
在游戏开发中,实现玩家的攻击功能是很重要的一部分。这里以玩家角色 Val 的飞刀攻击为例,当玩家点击攻击按钮时触发攻击动作。
- 修改
touchDown(:_)方法- 打开
GameScene.swift文件,修改touchDown(:_)方法如下:
- 打开
func touchDown(atPoint pos : CGPoint) {
let nodeAtPoint = atPoint(pos)
if let touchedNode = nodeAtPoint as? SKSpriteNode {
if touchedNode.name?.starts(with: "controller_") == true {
let direction = touchedNode.name?.replacingOccurrences(
of: "controller_", with: "")
player?.move(Direction(rawValue: direction ?? "stop")!)
} else if touchedNode.name == "button_attack" {
player?.at
超级会员免费看
订阅专栏 解锁全文
30

被折叠的 条评论
为什么被折叠?



