下記の様なソースなのですが2個以上選択すると左右の限界値を超えて
一回転してしまったり小刻みに動いたりと謎の減少が発生してしまいます。
なぜなのかイマイチわからないのですがソースが悪い部分がありますでしょうか?
//Mouse.touch.Flag マウスがクリックしているか
// フルーツ class FRUIT{ public: bool Flag; // 表示フラッグ float Rot; // 角度 bool TouchFlag; // タッチフラッグ void TouchRotation(void); }; // タッチした時のローテーション void FRUIT::TouchRotation(void){ static bool dir = false; // falseなら→に if( dir ) this->Rot += 1.0f; else this->Rot -= 1.0f; // 限界値 if( this->Rot >= 15 ) dir = false; if( this->Rot <= -15 ) dir = true; } static FRUIT Fruit[MAP_H][MAP_W]; //-------------------------------------------------// void Init(){ // フルーツ texFruit.imagePath = [[NSBundle mainBundle] pathForResource:@"fruit" ofType:@"png"]; texFruit.texture = SZGLLoadTexture(texFruit); // フルーツの初期化 for(int i=0; i<MAP_H; i++){ for(int j=0; j<MAP_W; j++){ Fruit[j].Flag = true; Fruit[j].Rot = 0; } } } void Loop(){ switch ( Game.Mode ) { case M_GAME: for(int i=0; i<MAP_H; i++){ for(int j=0; j<MAP_W; j++){ if( Fruit[j].Flag ){ // ローテーション関連 if( Mouse.touch.Flag && !Fruit[j].TouchFlag ){ int x = int((Mouse.touchX-16)/FRUIT_SIZE); int y = int((Mouse.touchY-48)/FRUIT_SIZE); if( x < 0 ) x = 0; if( x > MAP_W-1 ) x = MAP_W-1; if( y < 0 ) y = 0; if( y > MAP_H-1 ) y = MAP_H-1; Fruit[y][x].TouchFlag = true; } if( Fruit[j].TouchFlag ) Fruit[j].TouchRotation(); if( !Mouse.touch.Flag ){//&& Fruit[j].Rot == 0 ){ Fruit[j].TouchFlag = false; Fruit[j].Rot = 0; } } } } break; } }