Clip View for Game Play Scene
This is a small basic tool for the game. I want small box that reside on one of the corner of the scene. In which I want to show preview of whole game scene.
I have read all the thing and try as much as possible to get the thing done. I use SingleSceneSplitScreenEngine for this purpose. Following is my code snippet.
public class TwoCameraView extends BaseGameActivity implements
IOnSceneTouchListener {
private static int CAMERA_WIDTH = 1024;
private static int CAMERA_HEIGHT = 600;
private Camera mCamera, mChasingCamera;
private CameraScene mParentScene;
private TextureRegion loadingRegion;
@Override
public Engine onLoadEngine() {
mCamera = new Camera(0f, 0f, CAMERA_WIDTH, CAMERA_HEIGHT);
mChasingCamera = new BoundCamera(0, 0, 100f, 100f, 0, CAMERA_WIDTH, 0,
CAMERA_HEIGHT);
final EngineOptions engineOptions = new EngineOptions(true,
ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(
CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
engineOptions.getTouchOptions().setRunOnUpdateThread(true);
return new SingleSceneSplitScreenEngine(engineOptions, mChasingCamera);
}
private TextureRegion loadTextureRegion(int width, int height, String name) {
BitmapTextureAtlas BitmapTextureAtlas = new BitmapTextureAtlas(width,
height, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
TextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory
.createFromAsset(BitmapTextureAtlas, this, name, 0, 0);
getTextureManager().loadTextures(BitmapTextureAtlas);
return textureRegion;
}
@Override
public void onLoadResources() {
loadingRegion = loadTextureRegion(1024, 1024, "loading.png");
}
@Override
public Scene onLoadScene() {
mParentScene = new CameraScene(mCamera);
mParentScene.attachChild(new Sprite(0f, 0f, loadingRegion.deepCopy()));
mParentScene.setOnSceneTouchListener(this);
return mParentScene;
}
@Override
public void onLoadComplete() {
}
@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
if (pSceneTouchEvent.isActionMove()) {
mChasingCamera.setCenter(pSceneTouchEvent.getX(),
pSceneTouchEvent.getY());
return true;
}
return false;
}
}
I have modify the SingleSceneSplitScreenEngine of AndEngine library as per the following.
public class SingleSceneSplitScreenEngine extends Engine {
private final Camera mSecondCamera;
public SingleSceneSplitScreenEngine(final EngineOptions pEngineOptions,
final Camera pSecondCamera) {
super(pEngineOptions);
this.mSecondCamera = pSecondCamera;
}
@Deprecated
@Override
public Camera getCamera() {
return super.mCamera;
}
public Camera getFirstCamera() {
return super.mCamera;
}
pu
This is a small basic tool for the game. I want small box that reside on one of the corner of the scene. In which I want to show preview of whole game scene.
I have read all the thing and try as much as possible to get the thing done. I use SingleSceneSplitScreenEngine for this purpose. Following is my code snippet.
public class TwoCameraView extends BaseGameActivity implements
IOnSceneTouchListener {
private static int CAMERA_WIDTH = 1024;
private static int CAMERA_HEIGHT = 600;
private Camera mCamera, mChasingCamera;
private CameraScene mParentScene;
private TextureRegion loadingRegion;
@Override
public Engine onLoadEngine() {
mCamera = new Camera(0f, 0f, CAMERA_WIDTH, CAMERA_HEIGHT);
mChasingCamera = new BoundCamera(0, 0, 100f, 100f, 0, CAMERA_WIDTH, 0,
CAMERA_HEIGHT);
final EngineOptions engineOptions = new EngineOptions(true,
ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(
CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
engineOptions.getTouchOptions().setRunOnUpdateThread(true);
return new SingleSceneSplitScreenEngine(engineOptions, mChasingCamera);
}
private TextureRegion loadTextureRegion(int width, int height, String name) {
BitmapTextureAtlas BitmapTextureAtlas = new BitmapTextureAtlas(width,
height, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
TextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory
.createFromAsset(BitmapTextureAtlas, this, name, 0, 0);
getTextureManager().loadTextures(BitmapTextureAtlas);
return textureRegion;
}
@Override
public void onLoadResources() {
loadingRegion = loadTextureRegion(1024, 1024, "loading.png");
}
@Override
public Scene onLoadScene() {
mParentScene = new CameraScene(mCamera);
mParentScene.attachChild(new Sprite(0f, 0f, loadingRegion.deepCopy()));
mParentScene.setOnSceneTouchListener(this);
return mParentScene;
}
@Override
public void onLoadComplete() {
}
@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
if (pSceneTouchEvent.isActionMove()) {
mChasingCamera.setCenter(pSceneTouchEvent.getX(),
pSceneTouchEvent.getY());
return true;
}
return false;
}
}
I have modify the SingleSceneSplitScreenEngine of AndEngine library as per the following.
public class SingleSceneSplitScreenEngine extends Engine {
private final Camera mSecondCamera;
public SingleSceneSplitScreenEngine(final EngineOptions pEngineOptions,
final Camera pSecondCamera) {
super(pEngineOptions);
this.mSecondCamera = pSecondCamera;
}
@Deprecated
@Override
public Camera getCamera() {
return super.mCamera;
}
public Camera getFirstCamera() {
return super.mCamera;
}
pu
No comments:
Post a Comment