public void clearAll() { this.setVisible(false); ACTION = ACTION_DEFAULT; this.unregisterUpdateHandler(timerHandler); mCubicStartAniSprite.clearEntityModifiers(); mCubicStartAniSprite.clearUpdateHandlers(); mCubicStartAniSprite.stopAnimation(0); mCubicStartAniSprite.setVisible(false); mCubicTurnAniSprite.clearEntityModifiers(); mCubicTurnAniSprite.clearUpdateHandlers(); mCubicTurnAniSprite.stopAnimation(0); mCubicTurnAniSprite.setVisible(false); mCubicStopAniSprite.clearEntityModifiers(); mCubicStopAniSprite.clearUpdateHandlers(); mCubicStopAniSprite.stopAnimation(0); mCubicStopAniSprite.setVisible(false); mScrollLeftSprite.clearEntityModifiers(); mScrollLeftSprite.setVisible(false); for (int i = 0; i < mCubicTurnOptionAniSprite.length; i++) { mCubicTurnOptionAniSprite[i].setVisible(false); mCubicTurnOptionAniSprite[i].clearEntityModifiers(); mCubicTurnOptionAniSprite[i].clearUpdateHandlers(); mCubicTurnOptionAniSprite[i].stopAnimation(); } removePhysics(this); }
public CubicEntity( float pX, float pY, int pCubic, final ITiledTextureRegion pCubicStart, final ITiledTextureRegion pCubicTurn, final ITiledTextureRegion pCubicStop, final ITiledTextureRegion pCubicTurnOption[], ITextureRegion pTextureRegion) { super(pX, pY, pTextureRegion, mVertexBufferObjectManager); setAlpha(0.0f); TYPE = pCubic; mCubicStartAniSprite = new AnimatedSprite(0, 0, pCubicStart, mVertexBufferObjectManager); this.attachChild(mCubicStartAniSprite); mCubicStartAniSprite.setVisible(false); float turnX = getWidth() - pCubicTurn.getWidth(); float turnY = getHeight() - pCubicTurn.getHeight(); mCubicTurnAniSprite = new AnimatedSprite(turnX - 15, turnY - 15, pCubicTurn, mVertexBufferObjectManager); this.attachChild(mCubicTurnAniSprite); mCubicTurnAniSprite.setVisible(false); for (int i = 0; i < mCubicTurnOptionAniSprite.length; i++) { float turnOpX = getWidth() - pCubicTurnOption[i].getWidth(); float turnOpY = getHeight() - pCubicTurnOption[i].getHeight(); mCubicTurnOptionAniSprite[i] = new AnimatedSprite(turnOpX, turnOpY, pCubicTurnOption[i], mVertexBufferObjectManager); this.attachChild(mCubicTurnOptionAniSprite[i]); mCubicTurnOptionAniSprite[i].setVisible(false); } float stopX = getWidth() - pCubicTurn.getWidth(); float stopY = getHeight() - pCubicTurn.getHeight(); mCubicStopAniSprite = new AnimatedSprite(stopX - 15, stopY - 15, pCubicStop, mVertexBufferObjectManager); this.attachChild(mCubicStopAniSprite); mCubicStopAniSprite.setVisible(false); float scrollX = turnX + pCubicTurn.getWidth() / 2 - mScrollLeftTextureRegion.getWidth(); float scrollY = turnY + pCubicTurn.getHeight() - mScrollLeftTextureRegion.getHeight(); mScrollLeftSprite = new Sprite(scrollX, scrollY, mScrollLeftTextureRegion, mVertexBufferObjectManager); this.attachChild(mScrollLeftSprite); mScrollLeftSprite.setVisible(false); mScrollLeftSprite.registerEntityModifier( new LoopEntityModifier( new SequenceEntityModifier( new AlphaModifier(0.5f, 0.2f, 1.0f), new AlphaModifier(0.5f, 1.0f, 0.2f)))); }
// =========================================================== // Methods // =========================================================== private void addMario(final float pX, final float pY) { final Body body; final FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(1, 0.5f, 0.5f); mario = new AnimatedSprite(pX, pY, this.mMarioTextureRegion, this.getVertexBufferObjectManager()); mario.animate(new long[] {100, 100, 100}, 3, 5, true); body = PhysicsFactory.createBoxBody( this.mPhysicsWorld, mario, BodyType.DynamicBody, objectFixtureDef); marioRight = new AnimatedSprite(pX, pY, this.mMarioTextureRegion, this.getVertexBufferObjectManager()); marioRight.animate(new long[] {100, 100, 100}, 3, 5, true); // bodyRight = PhysicsFactory.createBoxBody(this.mPhysicsWorld, marioRight, // BodyType.DynamicBody, objectFixtureDef); marioLeft = new AnimatedSprite(pX, pY, this.mMarioTextureRegion, this.getVertexBufferObjectManager()); marioLeft.animate(new long[] {100, 100, 100}, 0, 2, true); // bodyLeft = PhysicsFactory.createBoxBody(this.mPhysicsWorld, marioLeft, BodyType.DynamicBody, // objectFixtureDef); // marioJump = new AnimatedSprite(pX, pY, this.mMarioJumpTextureRegion, // this.getVertexBufferObjectManager()); // marioJump.animate(new long[] { 100, 1000 }, 0, 1, true); this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(mario, body, true, true)); this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(marioRight, body, true, true)); this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(marioLeft, body, true, true)); // this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(marioJump, body, true, // true)); mario.setUserData(body); this.mScene.attachChild(mario); marioRight.setUserData(body); this.mScene.attachChild(marioRight); marioLeft.setUserData(body); this.mScene.attachChild(marioLeft); // marioJump.setUserData(body); // this.mScene.attachChild(marioJump); marioRight.setVisible(false); marioLeft.setVisible(false); // marioJump.setVisible(false); }
private void action(int action) { mCubicStartAniSprite.setVisible(false); mCubicStartAniSprite.stopAnimation(0); switch (action) { case ACTION_TURN_LEVEL_1: case ACTION_TURN_LEVEL_2: case ACTION_TURN_LEVEL_3: ACTION = action; final Body body = (Body) this.getUserData(); final Vector2 vector2 = Vector2Pool.obtain(body.getPosition()); int frame[] = new int[] {0, 1}; body.setAngularDamping(1.2f); vector2.x = vector2.x / 3; vector2.y = vector2.y / 3; if (action == ACTION_TURN_LEVEL_2) { frame = new int[] {2, 3}; body.setAngularDamping(2.2f); vector2.x = vector2.x / 2; vector2.y = vector2.y / 2; } else if (action == ACTION_TURN_LEVEL_3) { frame = new int[] {4, 5}; body.setAngularDamping(3.2f); } Vol3Osyougatsu.OGG_A3_A_5_KOMATEI.play(); mCubicTurnAniSprite.animate(new long[] {250, 250}, frame, -1); mCubicTurnAniSprite.setVisible(true); body.setActive(true); Log.i(TAG, "body.getPosition " + vector2); vector2.x = random(vector2.x) + new Random().nextFloat(); vector2.y = random(vector2.y) + new Random().nextFloat(); body.setLinearVelocity(vector2); Log.i(TAG, "body.getPosition change " + vector2); this.unregisterUpdateHandler(timerHandler); this.registerUpdateHandler( timerHandler = new TimerHandler( 6f, new ITimerCallback() { @Override public void onTimePassed(TimerHandler timerHandler) { // Stop Turn stopTurn(); } })); break; } }
@Override public void onPauseGame() { if (!isDrawView || !isPreView) { return; } Log.i(TAG, "-- onPauseGame --"); this.unregisterUpdateHandler(updateHandler); CUBIC_SLOT[0] = false; CUBIC_SLOT[1] = false; mArrowSprite.setVisible(false); mSuzuAniSprite.stopAnimation(0); mShishiAniSprite.stopAnimation(); mShishiAniSprite.clearEntityModifiers(); mShishiAniSprite.resetLocalToFirst(); mShishiAniSprite.setVisible(false); for (int i = 0; i < mCubicEntity.length; i++) { if (mCubicEntity[i] != null) { mCubicEntity[i].clearAll(); } } if (faceSequenceEntityModifier != null) { this.unregisterEntityModifier(faceSequenceEntityModifier); faceSequenceEntityModifier = null; } for (int i = 1; i < mTabSprite.length; i++) { mTabSprite[i].setVisible(false); } }
private void handAction(int pAction) { setVisibleHandDefault(false); switch (pAction) { case 2: // Door Human mHandActionAniSprite.setCurrentTileIndex(3); mHandActionAniSprite.setVisible(true); break; case 1: // Door ani case 0: mHandActionAniSprite.setCurrentTileIndex(4); mHandActionAniSprite.setVisible(true); break; case 3: mHandActionAniSprite.setCurrentTileIndex(5); mHandActionAniSprite.setVisible(true); break; } }
@Override public void onAccelerometerChanged(final AccelerometerData pAccelerometerData) { this.mGravityX = pAccelerometerData.getX(); this.mGravityY = pAccelerometerData.getY(); if (pAccelerometerData.getX() > 0) { marioMoveRight = true; marioMoveLeft = false; marioStand = false; } else if (pAccelerometerData.getX() == 0) { marioMoveLeft = false; marioMoveRight = false; marioStand = true; } else if (pAccelerometerData.getX() < 0) { marioStand = false; marioMoveLeft = true; marioMoveRight = false; } float bufX = mario.getX(); float bufY = mario.getY(); if (marioMoveLeft && mario != marioLeft) { mario.setVisible(false); mario = marioLeft; } else if (marioMoveRight && mario != marioRight) { mario.setVisible(false); mario = marioRight; } else if (marioStand) { mario.setVisible(false); } mario.setPosition(bufX, bufY); mario.setVisible(true); final Vector2 gravity = Vector2Pool.obtain(this.mGravityX * 5, this.mGravityY); this.mPhysicsWorld.setGravity(gravity); Vector2Pool.recycle(gravity); }
// Function Stop Turn when out time and collision "shishi" public void stopTurn() { Vol3Osyougatsu.OGG_A3_A_5_KOMATEI.stop(); ACTION = ACTION_TURN_STOP; for (int i = 0; i < mCubicTurnOptionAniSprite.length; i++) { mCubicTurnOptionAniSprite[i].stopAnimation(); mCubicTurnOptionAniSprite[i].setVisible(false); } mCubicTurnAniSprite.stopAnimation(0); mCubicTurnAniSprite.setVisible(false); removePhysics(CubicEntity.this); mCubicStopAniSprite.animate( new long[] {200, 1000}, new int[] {0, 1}, 0, new IAnimationListener() { @Override public void onAnimationStarted(AnimatedSprite arg0, int arg1) { mCubicStopAniSprite.setVisible(true); } @Override public void onAnimationLoopFinished(AnimatedSprite arg0, int arg1, int arg2) {} @Override public void onAnimationFrameChanged(AnimatedSprite arg0, int arg1, int arg2) { Log.i("XXX", arg1 + " Changed ID : " + arg2); int index = arg2; if (index == -1) { index = 0; } if (index >= 2) return; float width = mCubicStopAniSprite.getTiledTextureRegion().getWidth(index); float height = mCubicStopAniSprite.getTiledTextureRegion().getHeight(index); Log.i("XXX", width + " ~ " + height); mCubicStopAniSprite.setWidth(width); mCubicStopAniSprite.setHeight(height); } @Override public void onAnimationFinished(AnimatedSprite arg0) { CubicEntity.this.clearAll(); mCubicChooseSpite[CubicEntity.this.TYPE].setVisible(true); CUBIC_SLOT[SLOT] = false; checkArrow(); } }); }
private void touchToTurn(final int pAction) { Vol3Osyougatsu.OGG_A3_A_5_SPACE6.play(); final int ran = new Random().nextInt(mCubicTurnOptionAniSprite.length); if (ran == 0) { ACTION = ACTION_TURN_GIRL; } else if (ran == 1) { ACTION = ACTION_TURN_BOY; } else if (ran == 2) { ACTION = ACTION_TURN_FUNGI; } mCubicTurnAniSprite.stopAnimation(); mCubicTurnAniSprite.setVisible(false); mCubicTurnOptionAniSprite[ran].animate( new long[] {250, 250}, new int[] {0, 1}, 2, new IAnimationListener() { @Override public void onAnimationStarted(AnimatedSprite arg0, int arg1) { mCubicTurnOptionAniSprite[ran].setVisible(true); } @Override public void onAnimationLoopFinished(AnimatedSprite arg0, int arg1, int arg2) {} @Override public void onAnimationFrameChanged(AnimatedSprite arg0, int arg1, int arg2) {} @Override public void onAnimationFinished(AnimatedSprite arg0) { mCubicTurnOptionAniSprite[ran].setVisible(false); mCubicTurnOptionAniSprite[ran].stopAnimation(); ACTION = pAction; int frame[] = new int[] {0, 1}; if (ACTION == ACTION_TURN_LEVEL_2) { frame = new int[] {2, 3}; } else if (ACTION == ACTION_TURN_LEVEL_3) { frame = new int[] {4, 5}; } // run back... mCubicTurnAniSprite.animate(new long[] {250, 250}, frame, -1); mCubicTurnAniSprite.setVisible(true); } }); }
public void newEvent(float pX, float pY, int pSlot) { mCubicChooseSpite[TYPE].setVisible(false); SLOT = pSlot; CUBIC_SLOT[SLOT] = true; checkArrow(); this.setPosition(0, 100); ACTION = ACTION_DEFAULT; mCubicStartAniSprite.setVisible(true); mScrollLeftSprite.clearEntityModifiers(); mScrollLeftSprite.registerEntityModifier( new LoopEntityModifier( new SequenceEntityModifier( new AlphaModifier(0.5f, 0.2f, 1.0f), new AlphaModifier(0.5f, 1.0f, 0.2f)))); mScrollLeftSprite.setVisible(true); this.setVisible(true); final Body body = (Body) CubicEntity.this.getUserData(); Vector2 vector2 = Vector2Pool.obtain( pX / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT, pY / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT); body.setTransform(vector2, 0); Vector2Pool.recycle(vector2); }
private void handDefault() { setVisibleHandDefault(true); mHandActionAniSprite.setVisible(false); isHand = true; resetBaby(); }
@Override protected void loadKaraokeScene() { this.mScene = new Scene(); this.mScene.setOnAreaTouchTraversalFrontToBack(); this.mScene.setTouchAreaBindingOnActionDownEnabled(true); this.mScene.setTouchAreaBindingOnActionMoveEnabled(true); this.mScene.setOnSceneTouchListener(this); this.mScene.setBackground( new SpriteBackground( new Sprite(0, 0, mHaikeiTextureRegion, this.getVertexBufferObjectManager()))); mKaigaAnimatedSprite = new AnimatedSprite(162, 37, mKaigaTiledTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mKaigaAnimatedSprite); mTvAnimatedSprite = new AnimatedSprite(56, 226, mTvTiledTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mTvAnimatedSprite); mClockAnimatedSprite = new AnimatedSprite(616, 22, mClockTiledTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mClockAnimatedSprite); mClockAnimatedSprite.animate(new long[] {500, 500}, new int[] {0, 1}, -1); mClockCandyLeftSprite = new Sprite(575, -100, mClockCandyLeftTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mClockCandyLeftSprite); mDoorAnimatedSprite = new AnimatedSprite(696, 168, mDoorTiledTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mDoorAnimatedSprite); mDoorAnimatedSprite.setCurrentTileIndex(0); mClockCandyRightSprite = new Sprite(660, -95, mClockCandyRightTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mClockCandyRightSprite); mClockCandyLeftSprite.setVisible(false); mClockCandyRightSprite.setVisible(false); mSofaSprite = new Sprite(0, 0, mSofaTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mSofaSprite); mHandActionAniSprite = new AnimatedSprite( 156, 71, mHandActionTiledTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mHandActionAniSprite); mHandActionAniSprite.setVisible(false); mHandDefaultSprite = new Sprite(156, 71, mHandDefaultTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mHandDefaultSprite); final int FingerPoint[][] = new int[][] {{0, 114}, {57, 57}, {171, 0}, {284, 0}, {397, 114}}; for (int i = 0; i < 5; i++) { mFingerAnimatedSprite[i] = new FringerAnimatedSprite( 156 + FingerPoint[i][0], 71 + FingerPoint[i][1], mFingerTiledTextureRegion[i], this.getVertexBufferObjectManager()); this.mScene.attachChild(mFingerAnimatedSprite[i]); this.mScene.registerTouchArea(mFingerAnimatedSprite[i]); mFingerAnimatedSprite[i].setCurrentTileIndex(0); mFingerAnimatedSprite[i].idIndex = i; } mCryLeftSprite = new Sprite(584, 310, mCryLeftTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mCryLeftSprite); mCryLeftSprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); mCryLeftSprite.setVisible(false); mCryRightSprite = new Sprite(690, 335, mCryRightTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mCryRightSprite); // mCryRightSprite.setRotation(-90); mCryRightSprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); mCryRightSprite.setVisible(false); mMilkSprite = new MilkSprite(mMilkTextureRegion, this.getVertexBufferObjectManager()); this.mScene.attachChild(mMilkSprite); this.mScene.registerTouchArea(mMilkSprite); mMilkSprite.setVisible(false); addGimmicsButton( mScene, Vol3OhanashiResouce.SOUND_GIMMIC, new int[] { Vol3OhanashiResouce.main.A19_OHANASHI_1_IPHONE_ID, Vol3OhanashiResouce.main.A19_OHANASHI_2_IPHONE_ID, Vol3OhanashiResouce.main.A19_OHANASHI_3_IPHONE_ID }, mMainTexturePackLibs); }
protected void drawScene() { Log.i(TAG, "----------drawScene------------------------------"); this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, 0), false); this.registerUpdateHandler(mPhysicsWorld); this.mPhysicsWorld.setContactListener(contactListener); final Sprite spriteBackGround = new Sprite( 960 / 2 - mBackGroundTextureRegion.getWidth() / 2, 0, mBackGroundTextureRegion, mVertexBufferObjectManager); this.attachChild(spriteBackGround); for (int i = 0; i < mTabSprite.length; i++) { mTabSprite[i] = new Sprite( 960 / 2 - 1150 / 2, 89.5f, tpTab[i].getTexturePackTextureRegionLibrary().get(0), mVertexBufferObjectManager); this.attachChild(mTabSprite[i]); mTabSprite[i].setVisible(false); } mTabSprite[0].setVisible(true); final Body body = this.physicsEditorShapeLibrary.createBody( "a3_5_1_iphone_dai", mTabSprite[0], this.mPhysicsWorld); this.mPhysicsWorld.registerPhysicsConnector( new PhysicsConnector(mTabSprite[0], body, true, true)); mTabSprite[0].setUserData(body); // Cubic Choose mCubicChooseSpite[CUBIC_YELLOW] = new Sprite( 279, 70, tpOne .getTexturePackTextureRegionLibrary() .get(Vol3OsyougatsuResource.packer_parta_1.A3_6_4_IPHONE_KOMA_ID), mVertexBufferObjectManager); this.attachChild(mCubicChooseSpite[CUBIC_YELLOW]); mCubicChooseSpite[CUBIC_GREEN] = new Sprite( 200, 90f, tpOne .getTexturePackTextureRegionLibrary() .get(Vol3OsyougatsuResource.packer_parta_1.A3_6_3_IPHONE_KOMA_ID), mVertexBufferObjectManager); this.attachChild(mCubicChooseSpite[CUBIC_GREEN]); mCubicChooseSpite[CUBIC_BLUE] = new Sprite( 110, 107, tpOne .getTexturePackTextureRegionLibrary() .get(Vol3OsyougatsuResource.packer_parta_1.A3_6_2_IPHONE_KOMA_ID), mVertexBufferObjectManager); this.attachChild(mCubicChooseSpite[CUBIC_BLUE]); mCubicChooseSpite[CUBIC_ORANGE] = new Sprite( 22f, 135, tpOne .getTexturePackTextureRegionLibrary() .get(Vol3OsyougatsuResource.packer_parta_1.A3_6_1_IPHONE_KOMA_ID), mVertexBufferObjectManager); this.attachChild(mCubicChooseSpite[CUBIC_ORANGE]); cubicTouch = new CubicTouch(0, 0, 960, 640, null); this.attachChild(cubicTouch); this.registerTouchArea(cubicTouch); for (int i = CUBIC_ORANGE; i <= CUBIC_YELLOW; i++) { final TextureRegion iOTextureRegion = new TextureRegion( bitmapTexture[i % 2], 2, 2, mCubicStartTiledTexture[i].getWidth(), mCubicStartTiledTexture[i].getHeight()); mCubicEntity[i] = new CubicEntity( 0, 100, i, mCubicStartTiledTexture[i], mCubicTurnTiledTexture[i], mCubicStopTiledTexture[i], mCubicTurnOptionTiledTexture, iOTextureRegion); this.attachChild(mCubicEntity[i]); mCubicEntity[i].setVisible(false); // Body final Body bodyCubic = this.physicsEditorShapeLibrary.createBody( CUBIC_BODYNAME[i], mCubicEntity[i], this.mPhysicsWorld); bodyCubic.setFixedRotation(true); bodyCubic.setActive(false); mCubicEntity[i].setUserData(bodyCubic); mPhysicsWorld.registerPhysicsConnector( new PhysicsConnector(mCubicEntity[i], bodyCubic, true, true)); } final SceneTouch sceneTouch = new SceneTouch(0, 0, 960, 640, null); this.attachChild(sceneTouch); this.registerTouchArea(sceneTouch); mSuzuAniSprite = new AnimatedSprite( 960 / 2 - mSuzuTiledTexTure.getWidth() / 2, -19, mSuzuTiledTexTure, mVertexBufferObjectManager); this.attachChild(mSuzuAniSprite); mShishiAniSprite = new AnimatedSprite(960, 59.5f, mShishiTiledTexTure, mVertexBufferObjectManager); this.attachChild(mShishiAniSprite); mShishiAniSprite.setVisible(false); mArrowSprite = new Sprite( 120, 133, tpThree .getTexturePackTextureRegionLibrary() .get(Vol3OsyougatsuResource.packer_parta_3.A3_8_1_IPHONE_YAJIRUSHI_ID), mVertexBufferObjectManager); this.attachChild(mArrowSprite); mArrowSprite.setVisible(false); }