表情の変化
emotionプロパティで表情を指定することができます。指定すると感情にあわせて表情がアニメーションします。
ViewController.
self.romo.emotion = RMCharacterEmotionExcited;
感情は以下のように用意されています。
RMCharacterEmotionBewildered | 当惑 |
---|---|
RMCharacterEmotionCurious | 物珍しい |
RMCharacterEmotionDelighted | 喜び |
RMCharacterEmotionExcited | 興奮 |
RMCharacterEmotionHappy | 幸せ |
RMCharacterEmotionIndifferent | 無関心 |
RMCharacterEmotionSad | 悲しい |
RMCharacterEmotionScared | びっくり / 怖い |
RMCharacterEmotionSleepy | 眠い |
RMCharacterEmotionSleeping | 睡眠中 |
感情表現
expressionで,
ViewController.
self.romo.expression = RMCharacterExpressionAngry;
こちらは33通りもの感情表現が用意されています。感情の種類は RMCharacterExpression に規定されています。数が多いので,
また,
ViewController.
[self.romo setExpression:RMCharacterExpressionHappy withEmotion:RMCharacterEmotionHappy];
目のアニメーション
lookAtPointメソッドを使うことで視点を移動させることができます。以下のように書くことで,
ViewController.
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
self.romo.emotion = RMCharacterEmotionSleepy;
CGPoint touchPos = [[touches anyObject] locationInView:self.view];
CGFloat centerX = self.view.frame.size.width / 2;
CGFloat centerY = self.view.frame.size.height / 2;
CGFloat x = (touchPos.x - centerX) / centerX;
CGFloat y = (touchPos.y - centerY) / centerY;
CGFloat z = 0.0;
RMPoint3D lookPoint = RMPoint3DMake(x, y, z);
[self.romo lookAtPoint:lookPoint animated:YES];
}
RMPoint3Dで視点の位置を指定します。x,
タップ以外に,
次のように書くと,
[self.romo lookAtDefault];
また,
[self.romo setLeftEyeOpen:YES rightEyeOpen:NO];
まとめ
全3回の連載,
今回は
オリジナルのキャラクターを作成してみようと思った際にも,
また,
最近はロボット関係のニュースも良く耳にするようになりました。この連載をきっかけに,