iPhoneでopenframeworksをオブジェクト指向プログラミングを実行する時のメモ

iPhoneアプリが作りたくて最近色々しています。 「Apple Developer Program」のアクティベーションが受付ないので、appleに問い合わせ中なのでまだ実機で試してないのですが、それまでに一通りの知識をつけたいです。

iPhoneでopenframeworksを走らせる。

このブログを参考にすれば一通り実行することができますので、初めての方はまずこちらを実践してください。 非常にわかりやすく書かれています。

今回やりたいのは、下記の本のサンプルをiPhone上で実行することです。 Beyond Interaction ―メディアアートのためのopenFrameworksプログラミング入門 Beyond Interaction ―メディアアートのためのopenFrameworksプログラミング入門

ofBlob.h [cc lang="c"]

pragma once

include "ofMain.h"

class Blob {

public: void draw();

}; [/cc] ofBlob.cpp [cc lang="c"]

include "ofBlob.h"

void Blob::draw(){

ofSetColor(31,63,255); ofCircle(ofGetWidth()/2,ofGetHeight()/2,100);

} [/cc] testApp.cpp [cc lang="c++"]

include "testApp.h"

double angle;

//-------------------------------------------------------------- void testApp::setup(){ // register touch events ofRegisterTouchEvents(this);

// initialize the accelerometer ofxAccelerometer.setup();

//iPhoneAlerts will be sent to this. ofxiPhoneAlerts.addListener(this);

//If you want a landscape oreintation //iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT); ofBackground(0,0,0);

ofSetFrameRate(60);

}

//-------------------------------------------------------------- void testApp::update(){

}

//-------------------------------------------------------------- void testApp::draw(){

blob.draw();

}

//-------------------------------------------------------------- void testApp::exit(){

}

//-------------------------------------------------------------- void testApp::touchDown(ofTouchEventArgs &touch){

}

//-------------------------------------------------------------- void testApp::touchMoved(ofTouchEventArgs &touch){

}

//-------------------------------------------------------------- void testApp::touchUp(ofTouchEventArgs &touch){

}

//-------------------------------------------------------------- void testApp::touchDoubleTap(ofTouchEventArgs &touch){

}

//-------------------------------------------------------------- void testApp::lostFocus(){

}

//-------------------------------------------------------------- void testApp::gotFocus(){

}

//-------------------------------------------------------------- void testApp::gotMemoryWarning(){

}

//-------------------------------------------------------------- void testApp::deviceOrientationChanged(int newOrientation){

} [/cc]

testApp.hは初期のまま。

こうすれば、iPhone上でも色々なクラスを使って表現することができます。 ※privateの中ではofGetWidth()やofGetHeight()が使えない。