Ejemplo n.º 1
0
    public void updateMap(float dt) {
      // IMPORTANT
      //   The only limitation is that you cannot change an empty, or assign an empty tile to a tile
      //   The value 0 is not rendered so don't assign or change a tile with value 0

      TileMapAtlas tilemap = (TileMapAtlas) getChild(kTagTileMap);

      // For example you can iterate over all the tiles
      // using this code, but try to avoid the iteration
      // over all your tiles in every frame. It's very expensive
      //            	for(int x=0; x < tilemap.tgaInfo.width; x++) {
      //            		for(int y=0; y < tilemap.tgaInfo.height; y++) {
      //            			CCRGBB c = tilemap.tile(CCGridSize.ccg(x,y));
      //            			if( c.r != 0 ) {
      //            				Log.w(null, "%d,%d = %d", x,y,c.r);
      //            			}
      //            		}
      //            	}

      CCRGBB c = tilemap.tile(CCGridSize.ccg(13, 21));
      c.r++;
      c.r %= 50;
      if (c.r == 0) c.r = 1;

      tilemap.setTile(c, CCGridSize.ccg(13, 21));
    }
Ejemplo n.º 2
0
    public Atlas3() {
      Log.i(LOG_TAG, "Atlas3 starts");

      // TODO: This needs to be done when binding
      // Create an aliased Atlas
      Texture2D.saveTexParameters();
      Texture2D.setAliasTexParameters();

      TileMapAtlas tilemap = TileMapAtlas.tilemap("tiles.png", "small.tga", 16, 16);

      Texture2D.restoreTexParameters();

      addChild(tilemap, 0, kTagTileMap);

      tilemap.setAnchorPoint(0, 0);

      IntervalAction s = ScaleBy.action(4, 0.8f);
      IntervalAction scaleBack = s.reverse();
      IntervalAction go = MoveBy.action(8, -1650, 0);
      IntervalAction goBack = go.reverse();

      IntervalAction seq = Sequence.actions(s, go, goBack, scaleBack);

      tilemap.runAction(seq);
      Log.i(LOG_TAG, "Atlas3 ends");
    }
Ejemplo n.º 3
0
    public Atlas4() {
      Log.i(LOG_TAG, "Atlas4 starts");

      // Create an Aliased Atlas
      Texture2D.saveTexParameters();
      Texture2D.setAliasTexParameters();

      TileMapAtlas tilemap = TileMapAtlas.tilemap("tiles.png", "levelmap.tga", 16, 16);

      Texture2D.restoreTexParameters();

      // If you are not going to use the Map, you can free it now
      // tilemap.releaseMap();
      // And if you are going to use, it you can access the data with:
      schedule("updateMap", 0.2f);

      addChild(tilemap, 0, kTagTileMap);

      tilemap.setAnchorPoint(0, 0);
      tilemap.setPosition(-20, -200);

      Log.i(LOG_TAG, "Atlas4 starts");
    }