public TiledTextureRegion getTiledTextureFromPacker( TexturePack pTexturePack, int... pSpriteSheets) { final TexturePackTextureRegionLibrary mTexturePackTextureRegionLibrary = pTexturePack.getTexturePackTextureRegionLibrary(); final int sheetcount = pSpriteSheets.length; TexturePackerTextureRegion[] objTextureRegion = new TexturePackerTextureRegion[sheetcount]; for (int i = 0; i < sheetcount; i++) { objTextureRegion[i] = mTexturePackTextureRegionLibrary.get(pSpriteSheets[i]); } TiledTextureRegion mTiledTextureRegion = new TiledTextureRegion(pTexturePack.getTexture(), objTextureRegion); return mTiledTextureRegion; }
public void addGimmicsButton( Scene mScene, String[] sound, int[] image, TexturePackTextureRegionLibrary pTexturePackTextureRegionLibrary) { ITextureRegion[] ttrGimmic = new ITextureRegion[3]; sprGimmic = new Sprite[3]; final Sound[] sndGimmic = new Sound[3]; int[] start = {244, 436, 612}; for (int i = 0; i < sprGimmic.length; i++) { // load sound sndGimmic[i] = loadSoundResourceFromSD(sound[i]); ttrGimmic[i] = pTexturePackTextureRegionLibrary.get(image[i]); final int tmp = i; sprGimmic[i] = new Sprite(start[i], 496, ttrGimmic[i], this.getVertexBufferObjectManager()) { @Override public boolean onAreaTouched( final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) { if (isTouchGimmic[tmp]) { if (tmp == 2) { combineGimmic3WithAction(); } else { sndGimmic[tmp].play(); } sprGimmic[tmp].registerEntityModifier( new SequenceEntityModifier( new ScaleModifier(0.35f, 1, 1.3f), new ScaleModifier(0.35f, 1.3f, 1f))); } return true; } return super.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY); } }; mScene.registerTouchArea(sprGimmic[i]); mScene.attachChild(sprGimmic[i]); } mScene.setTouchAreaBindingOnActionDownEnabled(true); mScene.setTouchAreaBindingOnActionMoveEnabled(true); }
@Override protected void loadKaraokeResources() { mBackgroundTexturePack = mTexturePackLoaderFromSource.load("background.xml"); mHandSeeTexturePack = mTexturePackLoaderFromSource.load("handsee.xml"); mCaiTroGiuaTexturePack = mTexturePackLoaderFromSource.load("caitrogiua.xml"); mMainTexturePack = mTexturePackLoaderFromSource.load("main.xml"); mNhanUtTexturePack = mTexturePackLoaderFromSource.load("nhanut.xml"); mBackgroundTexturePack.loadTexture(); mHandSeeTexturePack.loadTexture(); mCaiTroGiuaTexturePack.loadTexture(); mMainTexturePack.loadTexture(); mNhanUtTexturePack.loadTexture(); mBackgroundTexturePackLibs = mBackgroundTexturePack.getTexturePackTextureRegionLibrary(); mMainTexturePackLibs = mMainTexturePack.getTexturePackTextureRegionLibrary(); mHaikeiTextureRegion = mBackgroundTexturePackLibs.get(Vol3OhanashiResouce.background.A19_12_IPHONE_HAIKEI_ID); mKaigaTiledTextureRegion = getTiledTextureFromPacker( mMainTexturePack, Vol3OhanashiResouce.main.A19_04_1_IPHONE_KAIGA_ID, Vol3OhanashiResouce.main.A19_04_2_IPHONE_KAIGA_ID, Vol3OhanashiResouce.main.A19_04_3_IPHONE_KAIGA_ID, Vol3OhanashiResouce.main.A19_04_4_IPHONE_KAIGA_ID, Vol3OhanashiResouce.main.A19_04_5_IPHONE_KAIGA_ID, Vol3OhanashiResouce.main.A19_04_6_IPHONE_KAIGA_ID); mTvTiledTextureRegion = getTiledTextureFromPacker( mMainTexturePack, Vol3OhanashiResouce.main.A19_05_1_IPHONE_TV_ID, Vol3OhanashiResouce.main.A19_05_2_IPHONE_TV_ID, Vol3OhanashiResouce.main.A19_05_3_IPHONE_TV_ID, Vol3OhanashiResouce.main.A19_05_4_IPHONE_TV_ID, Vol3OhanashiResouce.main.A19_05_5_IPHONE_TV_ID, Vol3OhanashiResouce.main.A19_05_6_IPHONE_TV_ID); mClockTiledTextureRegion = getTiledTextureFromPacker( mMainTexturePack, Vol3OhanashiResouce.main.A19_06_1_IPHONE_CLOCK_ID, Vol3OhanashiResouce.main.A19_06_2_IPHONE_CLOCK_ID, Vol3OhanashiResouce.main.A19_06_3_IPHONE_CLOCK_ID, Vol3OhanashiResouce.main.A19_06_6_IPHONE_CLOCK_ID); mSofaTextureRegion = mBackgroundTexturePackLibs.get(Vol3OhanashiResouce.background.A19_11_IPHONE_SOFA_ID); mDoorTiledTextureRegion = getTiledTextureFromPacker( mMainTexturePack, Vol3OhanashiResouce.main.A19_07_IPHONE_DOOR_ID, Vol3OhanashiResouce.main.A19_07_3_6_IPHONE_OJISAN_ID, Vol3OhanashiResouce.main.A19_07_1_1_IPHONE_KUMA_ID, Vol3OhanashiResouce.main.A19_07_1_2_IPHONE_KUMA_ID, Vol3OhanashiResouce.main.A19_07_2_1_IPHONE_USAGI_ID, Vol3OhanashiResouce.main.A19_07_2_2_IPHONE_USAGI_ID, Vol3OhanashiResouce.main.A19_07_3_1_IPHONE_OJISAN_ID, Vol3OhanashiResouce.main.A19_07_3_2_IPHONE_OJISAN_ID, Vol3OhanashiResouce.main.A19_07_3_3_IPHONE_OJISAN_ID, Vol3OhanashiResouce.main.A19_07_3_4_IPHONE_OJISAN_ID, Vol3OhanashiResouce.main.A19_07_3_5_IPHONE_OJISAN_ID); mClockCandyLeftTextureRegion = mMainTexturePackLibs.get(Vol3OhanashiResouce.main.A19_06_5_IPHONE_CLOCK_ID); mClockCandyRightTextureRegion = mMainTexturePackLibs.get(Vol3OhanashiResouce.main.A19_06_4_IPHONE_CLOCK_ID); mHandActionTiledTextureRegion = getTiledTextureFromPacker( mHandSeeTexturePack, Vol3OhanashiResouce.handsee.A19_08_1_1_IPHONE_JANKEN_ID, Vol3OhanashiResouce.handsee.A19_08_1_2_IPHONE_JANKEN_ID, Vol3OhanashiResouce.handsee.A19_08_1_3_IPHONE_JANKEN_ID, Vol3OhanashiResouce.handsee.A19_08_2_1_IPHONE_RENDOU_ID, Vol3OhanashiResouce.handsee.A19_08_2_2_IPHONE_RENDOU_ID, Vol3OhanashiResouce.handsee.A19_08_2_3_IPHONE_RENDOU_ID); mHandDefaultTextureRegion = mNhanUtTexturePack .getTexturePackTextureRegionLibrary() .get(Vol3OhanashiResouce.nhanut.A19_09_IPHONE_TENOHIRA_ID); mFingerTiledTextureRegion[0] = getTiledTextureFromPacker( mCaiTroGiuaTexturePack, Vol3OhanashiResouce.caitrogiua.A19_9A_1_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9B_1_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9C_1_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9D_1_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9E_1_1_IPHONE_ONAKANADERU_ID, Vol3OhanashiResouce.caitrogiua.A19_9E_1_2_IPHONE_ONAKANADERU_ID); mFingerTiledTextureRegion[1] = getTiledTextureFromPacker( mCaiTroGiuaTexturePack, Vol3OhanashiResouce.caitrogiua.A19_9A_2_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9B_2_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9C_2_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9D_2_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9E_2_1_IPHONE_ONAKANADERU_ID, Vol3OhanashiResouce.caitrogiua.A19_9E_2_2_IPHONE_ONAKANADERU_ID); mFingerTiledTextureRegion[2] = getTiledTextureFromPacker( mCaiTroGiuaTexturePack, Vol3OhanashiResouce.caitrogiua.A19_9A_3_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9B_3_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9C_3_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9D_3_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.caitrogiua.A19_9E_3_1_IPHONE_ONAKANADERU_ID, Vol3OhanashiResouce.caitrogiua.A19_9E_3_2_IPHONE_ONAKANADERU_ID); mFingerTiledTextureRegion[3] = getTiledTextureFromPacker( mNhanUtTexturePack, Vol3OhanashiResouce.nhanut.A19_9A_4_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.nhanut.A19_9B_4_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.nhanut.A19_9C_4_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.nhanut.A19_9D_4_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.nhanut.A19_9E_4_1_IPHONE_ONAKANADERU_ID, Vol3OhanashiResouce.nhanut.A19_9E_4_2_IPHONE_ONAKANADERU_ID); mFingerTiledTextureRegion[4] = getTiledTextureFromPacker( mNhanUtTexturePack, Vol3OhanashiResouce.nhanut.A19_9A_5_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.nhanut.A19_9B_5_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.nhanut.A19_9C_5_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.nhanut.A19_9D_5_IPHONE_DEFAULT_ID, Vol3OhanashiResouce.nhanut.A19_9E_5_1_IPHONE_ONAKANADERU_ID, Vol3OhanashiResouce.nhanut.A19_9E_5_2_IPHONE_ONAKANADERU_ID, Vol3OhanashiResouce.nhanut.A19_10_1_IPHONE_BABY_ID, Vol3OhanashiResouce.nhanut.A19_10_2_1_IPHONE_BABY_ID, Vol3OhanashiResouce.nhanut.A19_10_3_IPHONE_BABY_ID, Vol3OhanashiResouce.nhanut.A19_10_4_IPHONE_BABY_ID); mMilkTextureRegion = mMainTexturePackLibs.get(Vol3OhanashiResouce.main.A19_10_2_2_IPHONE_BABY_ID); mCryLeftTextureRegion = mMainTexturePackLibs.get(Vol3OhanashiResouce.main.A19_10_2_3_IPHONE_BABY_ID); mCryRightTextureRegion = mMainTexturePackLibs.get(Vol3OhanashiResouce.main.A19_10_2_4_IPHONE_BABY_ID); }