コード例 #1
0
  public void updateUV() {
    final ITexture texture = this.mTexture;
    final float textureWidth = texture.getWidth();
    final float textureHeight = texture.getHeight();

    final float x = this.getTextureX();
    final float y = this.getTextureY();

    this.mU = x / textureWidth;
    this.mU2 = (x + this.mTextureWidth) / textureWidth;

    this.mV = y / textureHeight;
    this.mV2 = (y + this.mTextureHeight) / textureHeight;

    //		this.mU = (x + 0.5f) / textureWidth;
    //		this.mU2 = (x + this.mTextureWidth - 0.5f) / textureWidth;
    //
    //		this.mV = (y + 0.5f) / textureHeight;
    //		this.mV2 = (y + this.mTextureHeight - 0.5f) / textureHeight;
  }
コード例 #2
0
  @Override
  protected void onCreateResources() {
    // TODO Auto-generated method stub
    try {
      // 1 - Set up bitmap textures
      ITexture backgroundTexture =
          new BitmapTexture(
              this.getTextureManager(),
              new IInputStreamOpener() {
                public InputStream open() throws IOException {
                  return getAssets().open("gfx/background.png");
                }
              });
      ITexture towerTexture =
          new BitmapTexture(
              this.getTextureManager(),
              new IInputStreamOpener() {
                public InputStream open() throws IOException {
                  return getAssets().open("gfx/tower.png");
                }
              });
      ITexture ring1 =
          new BitmapTexture(
              this.getTextureManager(),
              new IInputStreamOpener() {
                public InputStream open() throws IOException {
                  return getAssets().open("gfx/ring1.png");
                }
              });
      ITexture ring2 =
          new BitmapTexture(
              this.getTextureManager(),
              new IInputStreamOpener() {
                public InputStream open() throws IOException {
                  return getAssets().open("gfx/ring2.png");
                }
              });
      ITexture ring3 =
          new BitmapTexture(
              this.getTextureManager(),
              new IInputStreamOpener() {
                public InputStream open() throws IOException {
                  return getAssets().open("gfx/ring3.png");
                }
              });
      // 2 - Load bitmap textures into VRAM
      backgroundTexture.load();
      towerTexture.load();
      ring1.load();
      ring2.load();
      ring3.load();

      // 3 - Set up texture regions
      this.mBackgroundTextureRegion = TextureRegionFactory.extractFromTexture(backgroundTexture);
      this.mTowerTextureRegion = TextureRegionFactory.extractFromTexture(towerTexture);
      this.mRing1 = TextureRegionFactory.extractFromTexture(ring1);
      this.mRing2 = TextureRegionFactory.extractFromTexture(ring2);
      this.mRing3 = TextureRegionFactory.extractFromTexture(ring3);

      // 4 - Create the stacks
      this.mStack1 = new Stack();
      this.mStack2 = new Stack();
      this.mStack3 = new Stack();
    } catch (IOException e) {
      Debug.e(e.getStackTrace().toString());
    }
  }