Jump to content
  • Advertisement
Sign in to follow this  

Switching in-between tile layers [I STILL NEED HELP]

This topic is 4638 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Since I want my game to include multiple levels, I was wondering how I can go about in doing that. I tried to input numbers in my setMap method, but that didn't seem to work. I heard that you can do this by creating a method that merges two tile number arrays, representing the levels, into one, but I'm unsure as to how to proceed. Can someone please get back to me about this. Thank You. Here's my tile layer class (note: there will be more levels besides the ones currently stated):
package de.enough.polish.example;

import javax.microedition.lcdui.game.*;
import javax.microedition.lcdui.*;
public class TheLevels {
    private static final int [][] level1={
    private static final int [][] level2={
    private int TILE_WIDTH=64;
    private int TILE_HEIGHT=64;
    private int TILE_NUM_ROW = 3;
    private int TILE_NUM_COL = 18;

    private int [][] currentLevel;
    private TiledLayer theBoard;
    private int screenHeight;
    private int bgColor;

    /** Creates a new instance of TheLevels */
    public TheLevels(int screenHeight) throws Exception {
         this.screenHeight = screenHeight;
    public void setMap(int level) throws Exception{
        Image tileImages = null;
        switch (level){
             case 1:  tileImages = Image.createImage("/street.png");
                       currentLevel = level1;
             case 2:  tileImages = Image.createImage("/grass.png");
                        currentLevel = level2;
            theBoard = new TiledLayer(TILE_NUM_COL,TILE_NUM_ROW, tileImages, TILE_WIDTH, TILE_HEIGHT);
            for (int rows=0; rows<TILE_NUM_ROW; rows++) {
              for (int columns=0; columns<TILE_NUM_COL; columns++) {
        public TiledLayer getBackground(){
            return theBoard;
        public int getBackgroundColor() {
            return bgColor;
        public int getWidth(){
            return theBoard.getWidth();
        public int getHeight(){
            return theBoard.getHeight();


[Edited by - thelegendofzaku on April 3, 2006 11:35:36 AM]

Share this post

Link to post
Share on other sites
I figured out my problem, had to get rid of default case in my setMap method in my tile layer class. As a result, I was able to switch in between tile layers. Now I have another problem, I can't seem to invoke that method in my game canvas class, it's not working in my constructor, let alone my thread. I'm stumped! I don't have a clue as to where else I should invoke it. I have searched just about everywhere for this and found absolutely nothing.

[Edited by - thelegendofzaku on April 3, 2006 11:55:13 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!