0

I'm trying to create a stage which has an image of the background, called lvl1.jpg. This image is 1920x6000 pixels. I want to start the game by creating the stage and adding the player on top. I'm placing a few stationary enemies on the level which the player should avoid.

I want to achieve this by letting the stage (or background image) and the enemies moving up a few pixels with each update. The size of the game file screen is 1000 by 600 pixels. So my gameclass is larger then my screen size will be. Is this possible? If so, how can I achieve this?

Joetjah
  • 6,292
  • 8
  • 55
  • 90

1 Answers1

1

Yes, it is possible, but you should not directly use such a big bitmap anywhere, it's killing performance. And yes, it is possible for the game class to be bigger than stage size, look at Epic War 2 game for an example - it has a big battle scene that scrolls left-right on demand of the player.

In order for you to make such a game class, you should limit the actual screen presence to only the visible parts of your level. For this, research blitting techniques, which have a core concept of one visible Bitmap object with the size of a stage, whose BitmapData is redrawn each frame to display background, objects, player, monsters, etc.

As a first approach, you can have your Game class contain all the objects, including player, and change game.y so that the player is always within the stage boundaries.

Vesper
  • 18,599
  • 6
  • 39
  • 61
  • Clear information. The blitting-technique was exactly the thing I was looking for. I was wondering though, since that large bitmap is actually the level and thus only loaded once, will it still affect performance? Or will it only affect performance when using blitting? Or won't it affect performance after it's loaded? – Joetjah Mar 18 '13 at 07:48
  • It affects performance if it's displayed directly, not if blitted. Flash engine will have to read through the entire bitmap, not only through the displayed part, and occasionally interpolate pixels, which is performance heavy. You will anyway have to blit your level as background, be that `level1.jpg` the entire graphics of a level or just the background, so I don't speak about lowering performance when blitting. – Vesper Mar 18 '13 at 09:24