
今回のプロジェクトはタスク数が少ないのと、作業人数が二人と少ないので、Remember The Milk でリストを共有し、それぞれのタスクにタグで名前を付けて、簡易的にタスク管理をしてみました。
次回は Trac や Redmine などを使い、本格的にタスクの管理していこうと思います。
しかし、簡易的でもタスク管理をするのは作業効率的に良いですね。全体の進行度が分かるという利点以外に、可視可されていると「タスクに取り組まなければ」というやる気が出ます。
これだけ。簡単ですね。
1
2
3
| UIImage* uiImage = [UIImage imageNamed:name];
PMS1AppDelegate* app = getAppDelegateInstance();
UIImageWriteToSavedPhotosAlbum(uiImage, app, @selector(localSavedImage:didFinishSavingWithError:contextInfo:), NULL); |
保存が完了した時にアラートを出すようにしてみました。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| - (void)localSavedImage:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:(void *)contextInfo{
if(!error){
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"保存"
message:@"写真の保存ができました"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"OK",nil];
[alertView show];
[alertView release];
}else{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"保存"
message:@"写真の保存ができませんでした"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"OK",nil];
[alertView show];
[alertView release];
}
} |
前回、フレームバッファのサイズを 480×480 で作成しておけば、回転時も問題ないと書いてしまったけど、それは間違いでした。
【iPhoneでの画面の向きの正しい判定】
回転時には UIView の
1
2
| - (void)layoutSubviews {
} |
が呼ばれるので、UIView の frame を再設定して、フレームバッファを作成しなおせば完了。
1
2
3
4
5
| [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)view.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); |
view.layer のサイズでフレームバッファが作成される。
UIViewController を継承したクラスに以下のコードを書く事で、iPhoneの向きが自動で取得ができる。XCode で OpenGL のテンプレートから作成した場合は、UIViewController を自前で作成し間に挟む事。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| //----------------------------------------
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
//----------------------------------------
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
// 縦向きでホームボタンが下
case UIInterfaceOrientationPortraitUpsideDown:
// 縦向きでホームボタンが上
break;
case UIInterfaceOrientationLandscapeLeft:
// 横向きでホームボタンが左
case UIInterfaceOrientationLandscapeRight:
// 横向きでホームボタンが右
break;
}
}
//----------------------------------------
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
} |
willRotateToInterfaceOrientation は回転開始時に呼ばれ toInterfaceOrientation には回転後の方向が入るが、didRotateFromInterfaceOrientation は回転後に呼ばれ fromInterfaceOrientation には回転前の方向が入るので、最終的な方向を知りたいなら toInterfaceOrientation で判定しなければならない。
また、OpenGLのビューは自動で正しい方向に回転されるため、フレームバッファのサイズを480×480で作成してしまえば回転の対応も楽かもしれない。
画面回転時のフレームバッファの作成し直しはこちらで説明

画像ビューワーのiPhoneアプリを作っていますが、画像をスライドして切り替えるときに、写真と写真との境目がパッキリするのが非常に格好わるい。
そこで、スライド中は境目をぼかすようにしてみました。もちろんスライド後はぼかしが消えます。
技術的には、OpenGLで描画を行っていて、1枚の写真を3枚の四角形ポリゴンで構成し、両はじの2つのアルファ値を0にしています。
こんな感じでフリックできます。
コードはこちら。説明は開発を優先したいので割愛させてください。コードを感じ取ってください。
//--------------------------------
void ManualThum::touchesBegan(NSSet* touches, UIEvent* event){
for(UITouch *touch in touches){
UIView* view = Scene::getInstance()->getView();
CGPoint touchPos = [touch locationInView:view];
ms::Vector2n screenSize = Scene::getInstance()->getScreenSize();
if(touchPos.y >= (screenSize.y-THUM_FLICK_H)){
touchStartPos = touchPos;
touchNowPos = touchStartPos;
touchGapPos = CGPointMake(0.0f, 0.0f);
state = STATE_MOVE;
}
break;
}
}
//--------------------------------
void ManualThum::touchesMoved(NSSet* touches, UIEvent* event){
for(UITouch *touch in touches){
UIView* view = Scene::getInstance()->getView();
CGPoint touchPos = [touch locationInView:view];
ms::Vector2n screenSize = Scene::getInstance()->getScreenSize();
if(touchPos.y >= (screenSize.y-THUM_FLICK_H)){
CGPoint prevPos = touchNowPos;
touchNowPos = touchPos;
touchGapPos = CGPointMake(touchNowPos.x-prevPos.x, touchNowPos.y-prevPos.y);
}
break;
}
}
//--------------------------------
void ManualThum::touchesEnded(NSSet* touches, UIEvent* event){
for(UITouch *touch in touches){
UIView* view = Scene::getInstance()->getView();
CGPoint touchPos = [touch locationInView:view];
if(ABS(touchPos.x-touchStartPos.x) < 10.0f &&
ABS(touchPos.y-touchStartPos.y) 10.0){
slideSpeed = touchGapPos.x * 1000.0f;
state = STATE_THROW;
}
touchStartPos = CGPointMake(0.0f, 0.0f);
touchNowPos = touchStartPos;
touchGapPos = CGPointMake(0.0f, 0.0f);
}
break;
}
}
//--------------------------------
void ManualThum::touchesCancelled(NSSet* touches, UIEvent* event){
touchesEnded(touches, event);
}

iphone fps
ゲーム開発者の癖なのか、どうもFPSが気になってしまうので、画面下に表示するようにしました。
下のバーは60FPSの場合画面幅いっぱいまで伸びます。