problem with screen.

  ... discussions about development with the GLES1 branch of AndEngine.

problem with screen.

Postby diegosepa » Tue Jun 19, 2012 7:32 pm

I am developing an application for galaxy tab 7. Works in both normal and 7 inch in 10 inches.
The problem is that only works on Samsung Tablet. I just tested on another tablet (ZTE) but also 7 inches, but the images were distorted.
Can anyone help me?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public Engine onLoadEngine() {
  2.                 final DisplayMetrics displayMetrics = new DisplayMetrics();
  3.                 this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
  4.                 CAMERA_WIDTH = displayMetrics.widthPixels;
  5.                 CAMERA_HEIGHT = displayMetrics.heightPixels;
  6.                 this.camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
  7.                 final EngineOptions engineOptions = new EngineOptions(true,
  8.                                 ScreenOrientation.LANDSCAPE, new FillResolutionPolicy(),
  9.                                 this.camera);
  10.                 engineOptions.getTouchOptions().setRunOnUpdateThread(true);
  11.                 return new Engine(engineOptions);
  12.  
  13.         }
  14.  
  15.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
diegosepa
 
Posts: 81
Joined: Thu Apr 07, 2011 6:46 pm

Re: problem with screen.

Postby OzLark » Wed Jun 20, 2012 3:25 am

Do you have a screen shot of the distortion?

It could be related to texture atlas sizes as some devices can handle 2048x2048 where as others can only do 1024x1024... But that usually causes textures to just be black squares....
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Re: problem with screen.

Postby diegosepa » Wed Jun 20, 2012 4:22 am

Below the images.

Could tell me what to do?
Attachments
ZTE.png
The tablet version ZET
ZTE.png (138.38 KiB) Viewed 496 times
galaxyTab.png
The tablet version GALAXY TAB
galaxyTab.png (53.34 KiB) Viewed 496 times
diegosepa
 
Posts: 81
Joined: Thu Apr 07, 2011 6:46 pm

Re: problem with screen.

Postby OzLark » Wed Jun 20, 2012 4:28 am

I don't see any distortion? Are you referring to the different placement of the text? And the fact that they are overlapping on one device?

If so, that is just how you've calculated the position on the screen and the different resolutions between the different devices is yielding different results.

There are many ways to address this, firstly - how are you calculating the position of the text? Are you taking into consideration the screen resolution? What about your camera, what settings are you using? What ratio/resolution policy are you specifying in your engine options?
Last edited by OzLark on Wed Jun 20, 2012 4:38 am, edited 2 times in total.
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Re: problem with screen.

Postby diegosepa » Wed Jun 20, 2012 4:33 am

Exactly.
Not quite a distortion, the image is getting a zoom that other device.

As I'm setting is the first topic
diegosepa
 
Posts: 81
Joined: Thu Apr 07, 2011 6:46 pm

Re: problem with screen.

Postby OzLark » Wed Jun 20, 2012 4:37 am

You'll need to provide more info for us to be able to help you.. Let's start by answering my other questions:

OzLark wrote:There are many ways to address this, firstly - how are you calculating the position of the text? Are you taking into consideration the screen resolution? What about your camera, what settings are you using? What ratio/resolution policy are you specifying in your engine options?


And maybe show some code you are using (EngineOptions, CameraSettings, Sprite creation and placement, etc)...
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Re: problem with screen.

Postby diegosepa » Wed Jun 20, 2012 4:42 am

Ok .. all the code below

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.android;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import javax.microedition.khronos.opengles.GL10;
  6.  
  7. import org.anddev.andengine.engine.Engine;
  8. import org.anddev.andengine.engine.camera.Camera;
  9. import org.anddev.andengine.engine.options.EngineOptions;
  10. import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
  11. import org.anddev.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
  12. import org.anddev.andengine.entity.Entity;
  13. import org.anddev.andengine.entity.scene.Scene;
  14. import org.anddev.andengine.entity.scene.background.ColorBackground;
  15. import org.anddev.andengine.entity.scene.menu.MenuScene;
  16. import org.anddev.andengine.entity.scene.menu.MenuScene.IOnMenuItemClickListener;
  17. import org.anddev.andengine.entity.scene.menu.animator.IMenuAnimator;
  18. import org.anddev.andengine.entity.scene.menu.animator.SlideMenuAnimator;
  19. import org.anddev.andengine.entity.scene.menu.item.IMenuItem;
  20. import org.anddev.andengine.entity.scene.menu.item.SpriteMenuItem;
  21. import org.anddev.andengine.entity.scene.menu.item.TextMenuItem;
  22. import org.anddev.andengine.entity.scene.menu.item.decorator.ColorMenuItemDecorator;
  23. import org.anddev.andengine.entity.sprite.Sprite;
  24. import org.anddev.andengine.entity.text.Text;
  25. import org.anddev.andengine.entity.util.FPSLogger;
  26. import org.anddev.andengine.opengl.font.Font;
  27. import org.anddev.andengine.opengl.font.FontFactory;
  28. import org.anddev.andengine.opengl.texture.Texture;
  29. import org.anddev.andengine.opengl.texture.TextureOptions;
  30. import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
  31. import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
  32. import org.anddev.andengine.opengl.texture.region.TextureRegion;
  33. import org.anddev.andengine.opengl.texture.region.TextureRegionFactory;
  34. import org.anddev.andengine.ui.activity.BaseGameActivity;
  35.  
  36. import android.app.AlertDialog;
  37. import android.content.DialogInterface;
  38. import android.content.Intent;
  39. import android.graphics.Color;
  40. import android.text.Editable;
  41. import android.util.DisplayMetrics;
  42. import android.util.Log;
  43. import android.view.MenuItem;
  44. import android.widget.EditText;
  45.  
  46. public class TelaMenuActivity extends BaseGameActivity implements IOnMenuItemClickListener{
  47.  
  48.         private static int CAMERA_WIDTH;
  49.         private static int CAMERA_HEIGHT;
  50.  
  51.         protected static final int MENU_NOVOJOGO = 0;
  52.         protected static final int MENU_INSTRUCOES = MENU_NOVOJOGO + 1;
  53.         protected static final int MENU_QUIT = MENU_INSTRUCOES + 1;
  54.  
  55.         protected Camera mCamera;
  56.         protected Scene mMainScene;
  57.  
  58.         protected MenuScene mMenuScene;
  59.  
  60.         private BitmapTextureAtlas cenarioTexture;
  61.         private TextureRegion cenarioTextureRegion;
  62.         private BitmapTextureAtlas mMenuTexture;
  63.        
  64.         protected TextureRegion mNovoJogoTextureRegion;
  65.         protected TextureRegion mComoJogarTextureRegion;
  66.         protected TextureRegion mSairTextureRegion;
  67.         protected TextureRegion mMenuAlphaAux;
  68.  
  69.         public Engine onLoadEngine() {
  70.                 final DisplayMetrics displayMetrics = new DisplayMetrics();
  71.                 this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
  72.                 CAMERA_WIDTH = displayMetrics.widthPixels;
  73.                 CAMERA_HEIGHT = displayMetrics.heightPixels;
  74.                 this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
  75.                 return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new FillResolutionPolicy(), this.mCamera));
  76.         }
  77.  
  78.         public void onLoadResources() {
  79.                 this.cenarioTexture = new BitmapTextureAtlas(1024, 1024, TextureOptions.DEFAULT);
  80.                 this.cenarioTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.cenarioTexture, this, "gfx/tela_iniciall.png", 0, 0);
  81.  
  82.                 this.mMenuTexture= new BitmapTextureAtlas(2048,2048, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
  83.                 this.mNovoJogoTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mMenuTexture, this, "gfx/NOVOJOGO.png", 0, 0);
  84.                 this.mMenuAlphaAux = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mMenuTexture, this, "gfx/menuAlpha.png", 0, 50);
  85.                 this.mComoJogarTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mMenuTexture, this, "gfx/COMOJOGAR.png", 0,100 );
  86.                 this.mSairTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mMenuTexture, this, "gfx/SAIR.png",0, 200);
  87.                 this.mEngine.getTextureManager().loadTextures(this.cenarioTexture,this.tituloTexture, this.mMenuTexture);
  88.         }
  89.  
  90.         public Scene onLoadScene() {
  91.                 this.mEngine.registerUpdateHandler(new FPSLogger());
  92.                 this.mMenuScene = this.createMenuScene();
  93.                 this.mMainScene = new Scene();
  94.                 this.mMainScene.setBackgroundEnabled(false);
  95.                 this.mMainScene.attachChild(new Sprite(0, 0, this.cenarioTextureRegion));
  96.                 this.mMainScene.setChildScene(this.mMenuScene, false, true, true);
  97.                 return this.mMainScene;
  98.         }
  99.  
  100.         public void onLoadComplete() {
  101.                 // TODO Auto-generated method stub
  102.  
  103.         }
  104.  
  105.         public boolean onMenuItemClicked(MenuScene pMenuScene, IMenuItem pMenuItem,     float pMenuItemLocalX, float pMenuItemLocalY) {
  106.                 switch(pMenuItem.getID()) {
  107.                 case MENU_NOVOJOGO:
  108.                         Intent intent1=new Intent(TelaMenuActivity.this, MyQuimicaActivity.class);
  109.                         startActivity(intent1);
  110.                         return true;
  111.                 case MENU_INSTRUCOES:
  112.                         Intent intent2=new Intent(TelaMenuActivity.this, TelaInstrucoesActivity.class);
  113.                         startActivity(intent2);
  114.                         return true;
  115.                 case MENU_QUIT:
  116.                         this.finish();
  117.                         return true;
  118.                 default:
  119.                         return false;
  120.                 }
  121.         }
  122.  
  123.         protected MenuScene createMenuScene() {
  124.                 final MenuScene menuScene = new MenuScene(this.mCamera);
  125.                 final SpriteMenuItem novoJogoMenuItem = new SpriteMenuItem(MENU_NOVOJOGO, this.mNovoJogoTextureRegion);
  126.                 novoJogoMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  127.                 menuScene.addMenuItem(novoJogoMenuItem);
  128.                 final SpriteMenuItem novoJogoAlpha = new SpriteMenuItem(4, this.mMenuAlphaAux);
  129.                 menuScene.addMenuItem(novoJogoAlpha);
  130.                 final SpriteMenuItem comoJogarMenuItem = new SpriteMenuItem(MENU_INSTRUCOES, this.mComoJogarTextureRegion);
  131.                 comoJogarMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  132.                 menuScene.addMenuItem(comoJogarMenuItem);              
  133.                 final SpriteMenuItem comoJogarAlpha = new SpriteMenuItem(5,  this.mMenuAlphaAux);
  134.                 menuScene.addMenuItem(comoJogarAlpha);
  135.                 final SpriteMenuItem sairMenuItem = new SpriteMenuItem(MENU_QUIT, this.mSairTextureRegion);
  136.                 sairMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  137.                 menuScene.addMenuItem(sairMenuItem);
  138.  
  139.                 menuScene.setPosition(-10, -50);
  140.                 menuScene.buildAnimations();
  141.                 menuScene.setBackgroundEnabled(false);
  142.                 menuScene.setOnMenuItemClickListener(this);
  143.  
  144.                 return menuScene;
  145.         }
  146. }
  147.  
  148.  
Parsed in 0.056 seconds, using GeSHi 1.0.8.4
diegosepa
 
Posts: 81
Joined: Thu Apr 07, 2011 6:46 pm

Re: problem with screen.

Postby diegosepa » Wed Jun 20, 2012 3:58 pm

OzLark?
diegosepa
 
Posts: 81
Joined: Thu Apr 07, 2011 6:46 pm

Re: problem with screen.

Postby diegosepa » Wed Jun 20, 2012 4:15 pm

If anyone has some sample code that runs on all 7-inch tablets without problems can post?
diegosepa
 
Posts: 81
Joined: Thu Apr 07, 2011 6:46 pm

Re: problem with screen.

Postby OzLark » Thu Jun 21, 2012 6:33 am

Hi Sorry, I've not had a lot of time ..

First suggestion I'd make is to fix your camera size to a set resolution - I'm not sure what the best resolution is, but for now pick the resolution of your target device.

Then build your scene to that target resolution and then allow AndEngine to scale the scene up or down based on the end device resolution.

To do this, you specify (in EngineOptions) FillResolutionPolicy (will cause aspect ratio stretching on different ratio displays) or RatioResoultionPolicy (will cause black bands to fill screen where aspect ratio differs)..

So in summary, I think your issue is that you set your camera to the devices display width and height, but you don't handle that with your image/sprite creation and placement - so the easiest solution is the one I describe above.
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Next

Return to GLES1

Who is online

Users browsing this forum: Google [Bot] and 14 guests