×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Dec 2003
    Location
    turkey
    Posts
    8

    using drawPixels() method for tiled maps

    Hi everyone,
    i want to make a tile based game and i want to put all my tiles int one png.
    for drawing to screen i wantto get png's relatead area as byte array and draw screen with drawPixels method
    Is there any suggestion how can i do it?

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    14
    You can draw the tile picture onto a mutable offscreen Image object and extract the pixels into an array using the getPixels method(s) of the corresponding DirectGraphics object.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Location
    Zurich, Switzerland
    Posts
    16
    why would you want to draw the tiles with drawPixel()? you can use
    setClip() and drawImage() to have MIDP draw the pixels for you - that's quite a bit faster and easier to handle too!

    say you want to draw a 16x16 tile sitting at tile-location 2,3 in your tile-png to location x,y in your image:

    g.tranlate(x,y);
    g.setClip(0,0,16,16);
    g.drawImage(tileImage, -(2-1)*16, -(3-1)*16,Graphics.TOP | Graphics.LEFT);
    g.translate(-x,-y);

  4. #4
    Registered User
    Join Date
    Dec 2003
    Location
    turkey
    Posts
    8

    i got it

    thanks for replys
    i think i got it but i haven't tested it yet on the real device
    i used setClip this is the easiest way i read a lot in the forum about drawPixels and setClip..
    they say setClip is slow and i agree with them

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×