Apple Engine

Apple, iPhone, iOS, その周辺のことについて

2018-05-01から1ヶ月間の記事一覧

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その27

GameController クラスのセットアップ関数を見てゆく。 今回は音を設定しているオーディオ設定。 playSound(_ audioName: AudioSourceKind) AudioSourceKind の enum で指定されているオーディオソースの添字を playSound 関数に渡す。 指定した添字から音を…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その26

GameController クラスのセットアップ関数を見てゆく。 今回は敵キャラとパーティクルの設定 setupEnemies() 敵の設定。 こちらは以前に紹介しているので割愛。 appleengine.hatenablog.com loadParticleSystems(atPath path: String) パーティクルセットア…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その25

GameController クラスのセットアップ関数を見てゆく。 今回はカメラ設定 Fox2 では固定カメラの他に、プレイヤーキャラクターである Max を追尾するカメラがある。 追尾するカメラは、カメラ視点が変えられるものと、変えられないものの2つある。 紹介順の…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その24

GameController クラスのセットアップ関数を見てゆく。 量が多いため何回かに分ける予定。 セットアップ GameController クラスのイニシャライズ時にいくつかの関数が呼ばれる。 setupGameController() ゲームコントローラー設定。 Bluetooth で接続や切断さ…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その23

今回から何回かに分けて GameController クラスの中身をみてゆく。 クラスの宣言 NSObject としてクラスをつくり、先に設定した ExtraProtocols で各 delegate の宣言をしている。 class GameController: NSObject, ExtraProtocols { ... } 定数 / 変数 クラ…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その22

Fox2 のサンプルで中心的なクラス GameController がある GameController.swift について見てゆく。 GameController.swift は GameController クラス、設定用にグローバルの struct と enum、各プラットフォーム毎に GameController の宣言時で読み込むプロ…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その21

今回は、ScaredComponent.swift を見てゆく。 中身的には ChaserComponent.swift とほぼ同じ。 主な変更は GKGoal がプレイヤーキャラの Max を追いかけるのではなく、逃げる(遠ざかる)振る舞いをする。 ScaredComponent の中身 import こちらは SIMD の計…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その20

今回は、ChaserComponent.swift を見てゆく。 この GKComponent はプレイヤーキャラ Max を追いかける設定が行われている。 ChaserComponent の中身 import 中で移動座標の処理をしているため simd をインポートしている。 import GameplayKit import simd …

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その19

今回は、PlayerComponent.swift を見てゆく。 中身は Character クラスを取得する変数と update の変数があるだけ。 PlayerComponent クラスの中身 import GameplayKit class PlayerComponent: BaseComponent { public var character: Character! override f…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その18

BaseComponent.swift を見てゆく。 GameplayKit の GKComponent を使用したクラスと GKAgent2D の extension で構成されてり、 ここで作成された GKComponent は PlayerComponent、ChaserComponent、ScaredComponent で継承され、一部機能追加されている。 G…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その18

前回に続き BaseComponent.swift の前にそこで使用している GameplayKit の「Agents, Goals, and Behaviors」について見てゆく。 Agents, Goals, and Behaviors とは? エージェントに対して、なんらかの振る舞いと目標までのゴールを設定すると、エージェン…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その17

BaseComponent.swift の前にそこで使用している GameplayKit の Entities and Components について見てゆく。 Entities and Components とは? 所謂、エンティティ・コンポーネント・システム。 ざっくり説明すると、エンティティはプレイヤーキャラや敵キャ…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その16

Character.swift 過去の記事 Character.swift その1 「定数 / 変数 と グローバル関数」 Character.swift その2 「イニシャライズ関数」 Character.swift その3 「その他の関数とプロパティ その1」 Character.swift その4 「update 関数」 最後に残りの関数…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その15

Character.swift 過去の記事 Character.swift その1 「定数 / 変数 と グローバル関数」 Character.swift その2 「イニシャライズ関数」 Character.swift その3 「その他の関数とプロパティ その1」 今回は Character クラスの update 関数を見てゆく。 長い…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その14

Character.swift 過去の記事 Character.swift その1 「定数 / 変数 と グローバル関数」 Character.swift その2 「イニシャライズ関数」 今回は Character.swift での他の関数とプロパティを見てゆく。 node Character クラスの大本となる characterNode ノ…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その13

前回の続きで、Character クラス の関数を見てゆく。 Character クラスの初期化 init(scene: SCNScene) { super.init() loadCharacter() loadParticles() loadSounds() loadAnimations() } セットアップのため4つの変数が呼ばれる。 scene で SCNScene が設…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その12

Character.swift を見てゆく。 この Swift ファイルはプレイヤーキャラクターである Max の設定とグローバルの関数で構成されている。 キャラクター設定は NSObjct となっており、 GameController.swift の GameController のイニシャライズ時に setupCharac…

WWDC 2017 の SceneKit サンプル Fox 2 を調べる その11

今回は SimdExtensions.swift を調べていく。 以前から Apple の SceneKit のサンプルでは simd (Accelerate Framework と simd.h) を使用しており、 通常の Swift の計算より高速に行う事ができる。 https://developer.apple.com/documentation/accelerate/…