Problm with tiledlayer object not showing on screen!! plz help

im making a small chess game my chess board is made of Tiledlayer and my chess elements are also Tiledlayer wheneever a move is made i have to make changes to my chess elements cells. but i make changes and they appear on my tiledlayer object but dont show on screen...
when during game when i press FIRE_KEY first time my code goes to a thread and starts a rectangle which blinks and when i press fire again the tiled_layer is updated such that my chess element is moved from selected position to desired position.... but i dont c the change on screen....
here is the complete code of chess board class...
* @(#)ChessCanvas.java
* @author Aaqib
* @version 1.00 1007/9/19
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public class ChessCanvas extends GameCanvas implements Runnable{
     private  final int SCREEN_X = getWidth();
     private  final int SCREEN_Y = getHeight();
     private int boardSize = 128;
     // starting point of our chess game
     private int startX = (SCREEN_X - boardSize)/2;
     private int startY = (SCREEN_Y - boardSize)/2;
     // create bounding rectangle to know the end of chess board;
     private int endX = startX + boardSize;
     private int endY = startY + boardSize;
     private static final byte BOARD_COLUMN = 8;
     private static final byte BOARD_ROWS = 8;
     private static final byte TILE_DIMENSION = 16;
     // current X, Y position of cursor
     private byte currentCursorRow;
     private byte currentCursorColumn;
     // the row column which r selected
     private byte selectedRow;
     private byte selectedColumn;
     // the current pixel lcoations
     private int currentPixelX;
     private int currentPixelY;     
     // check if selected. convert curser to red
     private boolean selected = false;
     // background color
     private int white = 0xFCFCFC;
     // the chess board tiled Layer
     private TiledLayer tiledLayer;
     // the chess elements
     private TiledLayer chessElements;
     // layer Manager to add tiles and sprites;
     private LayerManager layerManager;
     // the cursor which selects and moves the objects
     private Sprite cursor;
     // matrix representing the chess board;
     private final byte chkBoard[][] ={
                                   {2,1,2,1,2,1,2,1},
                                   {1,2,1,2,1,2,1,2},
                                   {2,1,2,1,2,1,2,1},
                                   {1,2,1,2,1,2,1,2},
                                   {2,1,2,1,2,1,2,1},
                                   {1,2,1,2,1,2,1,2},
                                   {2,1,2,1,2,1,2,1},
                                   {1,2,1,2,1,2,1,2},
     private final byte elements[][] = {
                                          {6,2,5,4,3,5,2,6},
                                          {1,1,1,1,1,1,1,1},
                                          {0,0,0,0,0,0,0,0},
                                          {0,0,0,0,0,0,0,0},     
                                          {0,0,0,0,0,0,0,0},
                                          {0,0,0,0,0,0,0,0},
                                          {7,7,7,7,7,7,7,7},
                                          {12,8,11,10,9,11,8,12}          
     private Graphics g;
     // main constructor
    public ChessCanvas() {
         super(true);
              setFullScreenMode(true);
              init();
     * Initialize all GUI components
    public void init(){
      try{
             Image spriteImg = Image.createImage("/cursor.png");
             cursor = new Sprite(spriteImg,15,15);
             cursor.setRefPixelPosition(startX - TILE_DIMENSION, startY - TILE_DIMENSION);
            Image img = Image.createImage("/board.png");
            Image elmt = Image.createImage("/chess.png");
            tiledLayer = new TiledLayer(BOARD_COLUMN, BOARD_ROWS, img, TILE_DIMENSION, TILE_DIMENSION);
            chessElements = new TiledLayer(BOARD_COLUMN, BOARD_ROWS, elmt,16,16);
            layerManager = new LayerManager();           
            currentCursorRow = 5;
            currentCursorColumn = 6;
            for (int y = 0; y < BOARD_COLUMN; y++){
                 for (int x = 0; x < BOARD_ROWS; x++){
                      int grid = chkBoard[y][x];
                      int data = elements[y][x];
                      tiledLayer.setCell(x,y, grid);
                      chessElements.setCell(x,y,data);
            g = getGraphics();
            // sets the position of chess board in center
            tiledLayer.move(startX, startY);
            chessElements.move(startX,startY);
            layerManager.append(cursor);
            layerManager.append(chessElements);
            layerManager.append(tiledLayer);
            moveCursor(currentCursorColumn * TILE_DIMENSION, currentCursorRow * TILE_DIMENSION );
      catch(Exception exception ){
             System.out.println("exception in init method  --  "+exception.toString() );
    public void start(){
         Thread thread = new Thread(this);
         thread.start();         
    public void run(){
         while (true){
              // check game state;
              //checkState();
              // check the userinput
              checkUserInput();              
              updateScreen(g);
              flushGraphics();
              try{
                   Thread.currentThread().sleep(300);
              }catch(Exception exception){}
    private void checkUserInput(){
         int keyState = getKeyStates();
         switch(keyState){
              case FIRE_PRESSED:
                   if (selected){
                        selected = false;
                        // make the move
                        logging ("selected >>  row  "+selectedRow+"  column   >>  "+selectedColumn +"\n");
                        logging ("current >>  row   "+currentCursorRow+"  column   >>  "+currentCursorColumn +"\n");
                         int selectedItem = chessElements.getCell(selectedRow,selectedColumn);
                         logging("selected item  >>  "+selectedItem+"\n");
                         chessElements.setCell(currentCursorRow,currentCursorColumn,selectedItem);
                         chessElements.setCell(selectedRow,selectedColumn,0);
                         chessElements.setCell(6,6,7);
                         logging ("selected >>  row  "+selectedRow+"  column   >>  "+selectedColumn +"\n");
                        moveCursor(0,0);
                   }else{
                        selected = true;
                        selectedRow = currentCursorRow;
                        selectedColumn = currentCursorColumn;
                        chessElements.setCell(6,6,7);
                   animateSelectedItem();
              break;
              case UP_PRESSED:
                   if (!cursor.isVisible())
                        cursor.setVisible(true);          
                   if (currentCursorRow == 1){
                        if (currentCursorColumn == 8){
                             currentCursorColumn =1;
                             currentCursorRow = 8;
                             currentPixelX = -112;
                             currentPixelY = 112;
                             //moveCursor(-112,112);
                        }else{
                             currentCursorColumn++;
                             currentCursorRow = 8;
                             currentPixelX = TILE_DIMENSION;
                             currentPixelY = 112;
                             //moveCursor(TILE_DIMENSION,112);
                   else{
                        currentCursorRow--;
                        currentPixelX = 0;
                        currentPixelY = -TILE_DIMENSION;
                        //moveCursor(0,-TILE_DIMENSION);
                   moveCursor(currentPixelX,currentPixelY);
              break;
              case DOWN_PRESSED:
                   if (!cursor.isVisible())
                        cursor.setVisible(true);
                   if (currentCursorRow == 8){
                        if (currentCursorColumn == 8){
                             currentCursorColumn =1;
                             currentCursorRow = 1;
                             currentPixelX = -112;
                             currentPixelY = -112;
                             //moveCursor(-112,-112);
                        }else{
                             currentCursorColumn++;
                             currentCursorRow = 1;
                             currentPixelX = TILE_DIMENSION;
                             currentPixelY = -112;
                             //moveCursor(TILE_DIMENSION,-112);
                   else{
                        currentCursorRow++;
                        currentPixelX = 0;
                        currentPixelY = TILE_DIMENSION;
                        //moveCursor(0,TILE_DIMENSION);
                   moveCursor(currentPixelX, currentPixelY);
              break;
              case LEFT_PRESSED:
                   if (!cursor.isVisible())
                       cursor.setVisible(true);
                   if (currentCursorColumn == 1){
                        if (currentCursorRow == 1){
                             currentCursorColumn =8;
                             currentCursorRow = 8;
                             currentPixelX = 112;
                             currentPixelY = 112;
                             //moveCursor(112,112);
                        }else{
                             currentCursorColumn = 8;
                             currentCursorRow--;
                             currentPixelX = 112;
                             currentPixelY = -TILE_DIMENSION;                       
                             //moveCursor(112,-TILE_DIMENSION);
                   else{
                        currentCursorColumn--;
                        currentPixelX = -TILE_DIMENSION;
                        currentPixelY = 0;
                        //moveCursor(-TILE_DIMENSION,0);
                        moveCursor(currentPixelX, currentPixelY);
              break;
              case RIGHT_PRESSED:
                   if (!cursor.isVisible())
                       cursor.setVisible(true);
                   if (currentCursorColumn == 8){
                        if (currentCursorRow == 8){
                             currentCursorColumn =1;
                             currentCursorRow = 1;
                             currentPixelX = -112;
                             currentPixelY = -112;
                             //moveCursor(-112,-112);
                        }else{
                             currentCursorColumn = 1;
                             currentCursorRow++;
                             currentPixelX = -112;
                             currentPixelY = TILE_DIMENSION;
                             //moveCursor(-112,TILE_DIMENSION);
                   else{
                        currentCursorColumn++;
                        currentPixelX = TILE_DIMENSION;
                        currentPixelY = 0;
                        //moveCursor(TILE_DIMENSION,0);
                   moveCursor(currentPixelX,currentPixelY);
              break;
    public void updateScreen(Graphics g){
         g = getGraphics();
         // set the background color
         g.setColor(white);
         g.fillRect(0, 0, getWidth(), getHeight());
          // draw the board         
         tiledLayer.paint(g);
         // paint the cursor
         cursor.paint(g);
         // chess elements
         chessElements.paint(g);
    private void moveCursor(int x , int y){
         //logging(" cursor  >>   "+cursor.getFrame());
         // red cursor selected
         if (selected){
              //logging("red");
              cursor.setFrame(1);
         }else{
              // normal green cursor moving
              //logging("green");
              cursor.setFrame(0);
         cursor.move(x,y);
     * Animate the selected Item. runs a saperate thread;
    private void animateSelectedItem(){
         cursor.setVisible(false);
         new Thread(new Runnable() {
              Graphics g = getGraphics();
              public void run(){
                       while(selected){
                        try{
                             Thread.currentThread().sleep(600);
                        }catch(Exception exception){
                             System.out.println("exception in animating sprite");
                         g.setColor(0xF71302);
                         g.drawRect((startX+ (selectedColumn * TILE_DIMENSION))-16,
                                        (startY+ (selectedRow * TILE_DIMENSION))-16, 14, 14 );
                        flushGraphics();
         }).start();
    private void logging (String str){
         System.out.print(str);
}plz help me....
thanks :(

{color:#000080}I don't know whether that's the only thing wrong here, but I see 3 calls to getGraphics(). The documentation for javax.microedition.lcdui.game.GameCanvas.getGraphics() says:{color}
A new Graphics object is created and returned each time this method is called; therefore, the needed Graphics object(s) should be obtained before the game starts then re-used while the game is running.
{color:#000080}-- Your call to getGraphics() in updateScreen(Graphics g) will return the reference to the local variable represented by the parameter g, which will be out of scope as soon as the method returns.
-- Your call to getGraphics() in animateSelectedItem() assigns the reference to a newly declared local variable, which too will be out of scope when the method returns. (But this method includes flushGraphics() so just possibly this g is flushed to the display.)
db{color}

Similar Messages

  • Finder on my mac book pro is not showing the sidebar plz help .i have a mac book pro running on os x lion 10.7.5

    finder on my mac book pro is not showing the sidebar plz help .i have a mac book pro running on os x lion 10.7.5

    In Finder, Click View, then Show Sidebar - or ALT+CMD+S

  • W550i showing white screen plz help

    My w550i  is showing white screen .i have taken it to a technician.he says it is a software problem it is hanged.plz anyone provide me necessary software to repair it

    According to the SE website, the W550i no longer supports the update service, so you will need to contact your local service centre to get it repaired.

  • Web Template with Query Views not showing Variable Screen

    Hi, I have a Web Template using 3 Query Views based on a single query.  The Query has 2 mandatory variables (CALMONTH and VERSION).  When I execute the Web Template it does not prompt with the Variable Screen, and presents the report with the Variables that were in place when the view was saved/created.  I'd like the Variables to appear.
    1. Is this the correct behavior? 
    2. Is there any documentation that might describe this behavior.
    3. Should I just copy the query and create 3 queries instead?
    Note: I did a search in SDN and found lots of similar threads, but nothing exact.  Also, I know about forcing the variable screen, but I thought I shouldn't have to do this.
    Thanks!

    k forget the view, when you run the main query... do you get a pop up for variable screen,. yes or no?
    if you dont then try to run another query and see if you get the variable screen as well. if you dont then its a bug. if you do then something is wrong in your query and its having an issue, but if you do get the screen on your query then it is a setting in your web template not in your query.
    you can also try to run the query in RSRT backend ...

  • When searching files within folders does not show all? Plz help

    This problem occured recently, few days back.
    When searching a name or extention it does now show all the files with the same name or extention?

    Figured it out I used straight serial cable. put null modem adapter solved the problem.

  • What would cause images with captions to not show up?

    Still struggling with this issue. Images with captions are not showing up on the iPad preview.
    Please help!
    Thx!

    Hi Andrew,
    I have been struggling with this for days. I am working on it with Apple. We re-installed the software, I re-installed OSLion, I re-started in safe mode, looked at startup items, cache, etc.
    Now I am about to create a partition and test again to determine if the issue is with another software program on my system.
    BTW, I noticed this starting AFTER I upgraded to 1.1, but maybe that is a coincidence. Do you know if it started for you after the update? ALSO, check your help screen in IBA. Does it look the attached? This started happening at the same time as the caption/image issue.
    Please stay in touch as you the first person other than myself (that I know about), who is having this issue.
    I look forward to hearing if you have the Heklp issue.
    THANKS!
    Belinda

  • Suddenly - and for no reason that I can think of - my keyboard does not show on screen what I am typing. In other words it is gibberish.

    Suddenly - and for no reason that I can think of - my keyboard does not show on screen what I am typing. In other words it is gibberish. This is only happening in browsers (Firefox and Chrome) but is OK in Word, Excel etc
    This has just started today; yesterday, I downloaded a Zone Alarm update which was genuine and I have done a full scan for virus and malware – nothing!
    I have tried the FN+NumLock idea which I saw on the internet but that doesn’t seem to work.
    Any ideas?

    Do a malware check with some malware scanning programs on the Windows computer.<br>
    Please scan with all programs because each program detects different malware.<br>
    All these programs have free versions.
    Make sure that you update each program to get the latest version of their databases before doing a scan.
    *Malwarebytes' Anti-Malware:<br>http://www.malwarebytes.org/mbam.php
    *AdwCleaner:<br>http://www.bleepingcomputer.com/download/adwcleaner/<br>http://www.softpedia.com/get/Antivirus/Removal-Tools/AdwCleaner.shtml
    *SuperAntispyware:<br>http://www.superantispyware.com/
    *Microsoft Safety Scanner:<br>http://www.microsoft.com/security/scanner/en-us/default.aspx
    *Windows Defender: Home Page:<br>http://www.microsoft.com/windows/products/winfamily/defender/default.mspx
    *Spybot Search & Destroy:<br>http://www.safer-networking.org/en/index.html
    *Kasperky Free Security Scan:<br>http://www.kaspersky.com/security-scan
    You can also do a check for a rootkit infection with TDSSKiller.
    *Anti-rootkit utility TDSSKiller:<br>http://support.kaspersky.com/5350?el=88446
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • TS3694 i think itunes  has removed my iphone software. because now not showing home screen. when i tried to restore my phone there generated an error no is 1015. please help me how can i recover my iphone again?

    i think itunes  has removed my iphone software. because now not showing home screen. when i tried to restore my phone there generated an error no is 1015. please help me how can i recover my iphone again?

    From the article which you posted your question from:
    Errors related to downgrading iOS
    The required resource cannot be found: This alert message occurs when your device has a newer version of iOS than what is available in iTunes. When troubleshooting a device that presents this alert message, go to Settings > General > About and check the version of iOS on the device. If it is newer than the latest released iOS version, the device may have a prerelease developer version of iOS installed.   Installing an older version of iOS over a newer version is not supported.
    Error 1015: This error is typically caused by attempts to downgrade the iPhone, iPad, or iPod touch's software. This can occur when you attempt to restore using an older .ipsw file. Downgrading to a previous version is not supported. To resolve this issue, attempt to restore with the latest iPhone, iPad, or iPod touch software available from Apple. This error can also occur when an unauthorized modification of the iOS has occurred and you are now trying to restore to an authorized, default state.

  • DNG files created with LR4 do not show thumbnails

    Hi, 
    When using LR3 to create DNG files from my RAW files, those files would show me thumbnails of my image in Windows Explorer.  I am running Windows/7 (64) and have installed a CODEC from "Fast Picture Viewer" that allows thumbnails from RAW & DNG files to be shown.   It seems, however, that the thumbnails do not show for DNG's created with LR4.
    To Remedy this I uninstalled the CODEC.  Downloaded the most recent version and installed it but this did not fix the problem.
    I then went to the user forum for the CODEC product and searched for my problem.  I found a thread who's solution is to turn off "Embed Fast Load Data" when exporting to DNG and it fixes the problem.  I tried this and indeed it did fix it.  The responder went on to say ".....When this option is enabled the files created are no longer DNGs (just an undocumented private format of Adobe that no one else can read to this date)".   This statement surprised me as it is counter to what I understand Adobe created DNG to be.  Can I get some input on this comment as if true it is very troubling.
    My second question is that I see where to turn off the "Embed Fast Load Data" in the LR Export module, but where do I do the same thing in the Import module when I'm selecting import mode "Copy to DNG"?
    And, my thrid question is this.  If indeed the DNG files created by LR4 are proper DNG files and this CODEC is just flawed in some way, does anyone have a better way to allow image thumbnails to be shown in Windows Explorer?
    Thanks -- Dan

    Hi David,
    You testing does not coincide with mine.  I have consistently kept "Use
    lossy compression" turned off.  With lossy turned off, it seems that using
    Fast Data Load prevents the thumbnails from displaying whereas turning off
    "Fast Data Load" allows the thumbnail to be shown.
    Below is comment from Adobe confirming that they have yet to release the
    spec containing "Fast Data Load".
    From: Ian Lyons [email protected]
    Sent: Tuesday, June 05, 2012 12:29 AM
    To: Califdan
    Subject: DNG files created with LR4 do not show
    thumbnails
    Re: DNG files created with LR4 do not show thumbnails
    created by Ian Lyons in Photoshop Lightroom - View the full discussion

  • Hi, i am having a problem in my ipad 2 , it is not showing main screen just showing a black blank screen in which downloading icon is only shwn which is continously and when i connect to itunes via windows 7 it showing this error (0xE8000065) can any one

    hi, i am having a problem in my ipad 2 , it is not showing main screen just showing a black blank screen in which downloading icon is only shwn which is continously and when i connect to itunes via windows 7 it showing this error (0xE8000065) can any one

    First, try a system reset.  It cures many ills and it's quick, easy and harmless...
    Hold down the on/off switch and the Home button simultaneously until the screen blacks out or you see the Apple logo.  Ignore the "Slide to power off" text if it appears.  You will not lose any apps, data, music, movies, settings, etc.
    If the Reset doesn't work, try a Restore.  Note that it's nowhere near as quick as a Reset.  Connect via cable to the computer that you use for sync.  From iTunes, select the iPad/iPod and then select the Summary tab.  Follow directions for Restore and be sure to say "yes" to the backup.  You will be warned that all data (apps, music, movies, etc.) will be erased but, as the Restore finishes, you will be asked if you wish the contents of the backup to be copied to the iPad/iPod.  Again, say "yes."
    Finally, if the Restore doesn't work, let the battery drain completely.  Then recharge for at least an hour and Restore again.

  • My large monitor is not showing the screen of my MAC airbook on it. All cables are hooked up. I reset the pram  and still not working. Message on black monitor says"check signal cable...?

    My large monitor is not showing the screen of my MAC airbook on it. All cables are hooked up. I reset the pram per the instructions I received at the MAC store and the monitor is still not working. Message on blacked out monitor says"check signal cable". All cables are attached and monitor and MAC are both plugged into power source...Help ?

    Go to System Preferences, Display. Click on dectect displays.

  • Itouch goes through restore process then will not show home screen

    itouch goes through restore process then will not show home screen. Only apple logo shows and flashes periodically.

    - Try:
    iOS: Not responding or does not turn on
    - If not successful and you can't turn the iPod fully off, let the battery fully drain. After charging for at least an hour try the article again.
    - If still problem that indicates a hardware problem and an appointment at the genius Bar of an Apple store is in order.

  • What causes iphone 3gs every time I insert the SIM card does not show the screen or no service?

    what causes iphone 3gs every time I insert the SIM card does not show the screen or no service?

    If the iPhone was unlocked unofficially, it has been locked to original carrier again.

  • Not showing Variable screen in Workbook - Refresh

    Hi BW Experts,
    I am working on BI 7.0
    When I try to refresh Workbook in Analyzer it is refreshing the query giving current data, but it is not showing Variable screen.
    What should I do to open variable screen when I click on Refresh button in Workbooks.
    Kindly advise.
    Ram,

    You should click the 'refresh variable values' button.
    Also switch on the 'process variables on refresh' in the workbook properties.

  • TS3276 Does anyone have problems with sent messages not showing in their Mail? I have two sent folders when really I only want one. Any tips?

    Does anyone have problems with sent messages not showing in their Mail? I have two sent folders when really I only want one. Any tips?

    Not sure if this is a fix, but I tried sending myself a test email from only  the Bcc field, and lo and behold it now shows the Bcc field in all sent item previews;
    ...maybe leaving the 'To' field blank on purpose forced Mail to show it.
    Rebooted the Mail program, still there - rebooted the machine, still there. Hope this is still relevant and it works for you too - J.

Maybe you are looking for

  • How can I connect my G5 iMac to Telefonica ADSL?

    I just moved to Spain. The ADSL connection offered by telefonica seems to be set up with just PCs in mind. I do not know how I can connect my iMAc and my extreme Airport Base Station to that ADSL system. Do I need any special configuration in the Bas

  • T400 Screen turns Black/Gray and System Freezes.

    My screen turns black or gray and the system freezes. The only way to fix it is to restart the system by opening all forms of power supply (adaptor and the battery). Sometimes it works fine for a day or two, sometimes only for a few hours. I think th

  • Difference impact on Net Value

    Hi All, Similar questions have been answered but this has not solved my queries so I have to post. the user wants to post the difference in amount received and invoice amount in some loss account. this is happening but in doing this, I have to give t

  • Data from iCal to Filemaker

    I´m building a calendar in Filemaker and need to import data from iCalendar. Any suggestions? npfs imac   Mac OS X (10.4.8)  

  • Problems installing DLNA software

    Hi again, I have had good support from the community in the past and I wonder if anyone can help me with the installation of DLNA server software? I installed the JRiver Media Centre yesterday with a fully paid licence. However I find that the softwa