@Override public Scene onLoadScene() { this.mEngine.registerUpdateHandler(new FPSLogger()); final Scene scene = new Scene(1); scene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f)); /* Calculate the coordinates for the screen-center. */ final int centerX = (CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2; final int centerY = (CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2; /* Create some faces and add them to the scene. */ final IEntity lastChild = scene.getLastChild(); lastChild.attachChild(new Sprite(centerX - 25, centerY - 25, this.mFaceTextureRegion)); lastChild.attachChild(new Sprite(centerX + 25, centerY - 25, this.mFaceTextureRegion)); lastChild.attachChild(new Sprite(centerX, centerY + 25, this.mFaceTextureRegion)); scene.setOnSceneTouchListener( new IOnSceneTouchListener() { @Override public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) { switch (pSceneTouchEvent.getAction()) { case TouchEvent.ACTION_DOWN: ZoomExample.this.mSmoothCamera.setZoomFactor(5.0f); break; case TouchEvent.ACTION_UP: ZoomExample.this.mSmoothCamera.setZoomFactor(1.0f); break; } return true; } }); return scene; }
@Override public Scene onLoadScene() { this.mEngine.registerUpdateHandler(new FPSLogger()); final Scene scene = new Scene(1); scene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f)); /* Create the icons and add them to the scene. */ final IEntity lastChild = scene.getLastChild(); lastChild.attachChild(new Sprite(160 - 24, 106 - 24, this.mPngTextureRegion)); lastChild.attachChild(new Sprite(160 - 24, 213 - 24, this.mJpgTextureRegion)); lastChild.attachChild(new Sprite(320 - 24, 106 - 24, this.mGifTextureRegion)); lastChild.attachChild(new Sprite(320 - 24, 213 - 24, this.mBmpTextureRegion)); return scene; }
private void initLevelBorders(final Scene pScene) { final Shape topOuter = new Rectangle(0, 0, LEVEL_WIDTH * 2, 2); final Shape bottomOuter = new Rectangle(0, LEVEL_HEIGHT - 2, LEVEL_WIDTH * 2, 2); final Shape leftOuter = new Rectangle(0, 0, 2, LEVEL_HEIGHT); final Shape rightOuter = new Rectangle(LEVEL_WIDTH * 2 - 2, 0, 2, LEVEL_HEIGHT); final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f); PhysicsFactory.createBoxBody( this.mPhysicsWorld, bottomOuter, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody(this.mPhysicsWorld, topOuter, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody( this.mPhysicsWorld, leftOuter, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody( this.mPhysicsWorld, rightOuter, BodyType.StaticBody, wallFixtureDef); final IEntity firstChild = pScene.getChild(LAYER_BORDERS); firstChild.attachChild(bottomOuter); firstChild.attachChild(topOuter); firstChild.attachChild(leftOuter); firstChild.attachChild(rightOuter); }
private void initLevel(final Scene pScene) { final IEntity levelEntity = pScene.getChild(LAYER_RACETRACK); levelEntity.attachChild(new Sprite(0, 0, LEVEL_WIDTH, LEVEL_HEIGHT, mLevelTextureRegion)); levelEntity.attachChild( new Sprite(LEVEL_WIDTH, 0, LEVEL_WIDTH, LEVEL_HEIGHT, mLevelTextureRegion)); }