Timeline for How to only render whats on screen (Tilemap, Java2D)
Current License: CC BY-SA 3.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 13, 2017 at 12:18 | history | edited | CommunityBot | replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/ | |
| Jun 27, 2015 at 12:14 | comment | added | Raildex | I solved it. the loop was for(int col = 0; col < view.getWidth()/TILE_SIZE;col++) now it's for(int col = startCol; col < colEnd-colStart;col++) where colStart = view.getX()/TILE_SIZE and colEnd = view.getX()+view.getWidth()/TILE_SIZE Thank your for your help guys :) | |
| Jun 25, 2015 at 21:48 | comment | added | Sandalfoot | Possibly. At this point you're going to have to dig in and do some debugging to see where the problem lies. I'd definitely start with that method. Also, you are calculating the number of vertically visible rows using view.getWidth() instead of view getHeight() - which isn't even really necessary because you're not trying to draw across the entire height of the screen. | |
| Jun 25, 2015 at 21:31 | comment | added | Raildex | the problem keeps unsolved. Is it because of my checkBounds Method? pastebin.com/qV7bx7rd | |
| Jun 25, 2015 at 21:10 | comment | added | Sandalfoot | You're calculating a negative offset and then subtracting it from the draw coordinates instead of adding it. That's what's giving you the reversed offset adjustment. Change lines 18 and 19 to "+ offsetX", or just remove the - signs from your offset calculation. | |
| Jun 25, 2015 at 21:02 | comment | added | Raildex | Thank you for your help, but the problem remains unsolved. My method now looks like this: pastebin.com/dVWZyUeq | |
| Jun 25, 2015 at 18:15 | history | edited | Sandalfoot | CC BY-SA 3.0 | added 77 characters in body |
| Jun 25, 2015 at 17:47 | comment | added | Sandalfoot | I see two problems. The first is that it looks like the offset is reversed - you're adding it instead of subtracting it. Also, you didn't modify the end condition of your loop. You need to draw tile_number + num_visible, not just num_visible as it still assumes your loop begins at tile_num 0. | |
| Jun 25, 2015 at 14:01 | vote | accept | Raildex | ||
| Jun 25, 2015 at 12:11 | comment | added | Raildex | Oh thank you very much, this offset was missing, but it somehow scrolls very weird. dl.dropboxusercontent.com/u/13341521/scroll.mp4 | |
| Jun 25, 2015 at 1:57 | history | edited | Sandalfoot | CC BY-SA 3.0 | added 146 characters in body |
| Jun 25, 2015 at 1:30 | review | First posts | |||
| Jun 25, 2015 at 5:09 | |||||
| Jun 25, 2015 at 1:26 | history | answered | Sandalfoot | CC BY-SA 3.0 |