Back to project page ssniper-andengine.
The source code is released under:
Apache License
If you think the Android project ssniper-andengine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.cladophora.ssniper.scene; /*w w w . j av a2 s . c o m*/ import android.widget.Toast; import com.cladophora.ssniper.BaseActivity; import com.cladophora.ssniper.R; import org.andengine.entity.IEntity; import org.andengine.entity.modifier.DelayModifier; import org.andengine.entity.modifier.IEntityModifier.IEntityModifierListener; import org.andengine.entity.scene.IOnSceneTouchListener; import org.andengine.entity.scene.Scene; import org.andengine.entity.scene.background.Background; import org.andengine.entity.sprite.Sprite; import org.andengine.entity.text.Text; import org.andengine.input.touch.TouchEvent; import org.andengine.opengl.texture.TextureOptions; import org.andengine.opengl.texture.atlas.ITextureAtlas; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; import org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource; import org.andengine.opengl.texture.region.ITextureRegion; import org.andengine.util.color.Color; import org.andengine.util.modifier.IModifier; public class WeaponInfoScene extends Scene implements IOnSceneTouchListener { BaseActivity activity; public Sprite rifleSideView; public ITextureRegion mRifleSideTR; public BitmapTextureAtlas rifleSideViewBTA; public WeaponInfoScene() { setBackground(new Background(Color.WHITE)); activity = BaseActivity.getSharedInstance(); loadGraphics(); rifleSideView = new Sprite(0,0, mRifleSideTR, activity.getVertexBufferObjectManager()); final float x0 = (BaseActivity.CAMERA_WIDTH / 2) - (rifleSideView.getWidth()/ 2); final float y0 = 10; rifleSideView.setPosition(x0,y0); rifleSideView.detachSelf(); attachChild(rifleSideView); String weaponInfo = activity.getString(R.string.weaponinfotext0) + "\n" + activity.getString(R.string.weaponinfotext1) + "\n" + activity.getString(R.string.weaponinfotext2) + "\n" + activity.getString(R.string.weaponinfotext3) + "\n" + activity.getString(R.string.weaponinfotext4); final Text weaponInfoText = new Text(0, 0, BaseActivity.mNotoSansFont, weaponInfo, activity.getVertexBufferObjectManager()); weaponInfoText.setColor(Color.BLACK); final float weaponInfo_x0 = (BaseActivity.CAMERA_WIDTH / 2) - (weaponInfoText.getWidth() / 2); final float weaponInfo_y0 = (BaseActivity.CAMERA_HEIGHT / 2) - (weaponInfoText.getHeight() / 2); weaponInfoText.setPosition(weaponInfo_x0, weaponInfo_y0); weaponInfoText.detachSelf(); attachChild(weaponInfoText); final WeaponInfoScene scene = this; DelayModifier delayModifier = new DelayModifier(0.2f, new IEntityModifierListener() { @Override public void onModifierStarted(IModifier<IEntity> arg0, IEntity arg1) { } @Override public void onModifierFinished(IModifier<IEntity> arg0, IEntity arg1) { setOnSceneTouchListener(scene); } } ); registerEntityModifier(delayModifier); } private void loadGraphics() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); final ITextureAtlas.ITextureAtlasStateListener.TextureAtlasStateAdapter<IBitmapTextureAtlasSource> textureAtlasStateListener = new ITextureAtlas.ITextureAtlasStateListener.TextureAtlasStateAdapter<IBitmapTextureAtlasSource>() { @Override public void onTextureAtlasSourceLoadExeption(final ITextureAtlas<IBitmapTextureAtlasSource> pTextureAtlas, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final Throwable pThrowable) { activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, "Failed loading TextureSource: " + pBitmapTextureAtlasSource.toString(), Toast.LENGTH_LONG).show(); } }); } }; rifleSideViewBTA = new BitmapTextureAtlas(activity.getTextureManager(), 979, 235, TextureOptions.BILINEAR, textureAtlasStateListener); mRifleSideTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset(rifleSideViewBTA, activity, "rifle-side.png", 0, 0); rifleSideViewBTA.load(); } @Override public boolean onSceneTouchEvent(Scene arg0, TouchEvent arg1) { // unload rifleSideView.dispose(); rifleSideViewBTA.unload(); rifleSideView.detachSelf(); activity.setCurrentScene(new GameScene()); return false; } }