Flash pinball

I just finished making pinball game for corona extra - the box2d engine works just fine, unfortuantely graphics use to much cpu power, so the game might slow down a bit ...you can always lower quality ( I forgot to disable right button menu 😉 )

here's the link
Cool! Runs fine for me, I'm wondering how the graphics could require that much cpu? I know using sprites and such can be slow, but mostly it is just the ball moving around and panning up/down. You should be able to use copyPixels method easily I would think because because there is no complicated shape rotation.
brainclog wrote:
Cool! Runs fine for me, I'm wondering how the graphics could require that much cpu? I know using sprites and such can be slow, but mostly it is just the ball moving around and panning up/down. You should be able to use copyPixels method easily I would think because because there is no complicated shape rotation.

That's right, i'm moving sprite with ball around the stage, also top of the table is a png image with alpha channel, so are (cutted to litle pieces) both ramps.

So you say it would be better to copy pixels instead of moving the ball sprite around the table?
I'll probably try it, when i have a free moment.

One more thing that requires cpu is sound - hane no idea why ❓

I did a modification, so that, when a framerata is too low, i'm changing quality to low, and it works smoother.
Yeah if you load everything into BitmapData objects, and then just have one Bitmap on the stage which you copyPixels into it is A LOT faster! You can still use alpha channel too, and it's about 10x faster than using "draw". Just make sure mergeAlpha parameter on copyPixels is set to true. Also call lock() on the BitmapData object before you start doing all your copyPixels stuff, and then when you are done with that frame, call unlock(). That stops the image on the screen from being updated, which can happen if there are a lot of copyPixels calls and it happens to try to do a frame update in the middle.

I have noticed sound can be a performance hit too, especially if you are playing too many at once. I wonder if it's because Flash keeps mp3s in that form to play them. I can't seem to get WAVs to embed... It would be really nice if there was a function to cache mp3s to WAV files after they load.
Great game, though I've never had any ability with pinball games. It looks to me like sound is the main drag, on my computer there is latency between each effect. Could be nothing fixable about it... Also, you cannot set the game to low quality, it just sets it back to high each time you lose a ball.

imbryk, did you use my b2ConcaveArcShape code in the end? I'm guessing not, given the level layout.
BorisTheBrave wrote:
Also, you cannot set the game to low quality, it just sets it back to high each time you lose a ball.
I've made a mechanism, which sets the quality to low, when framerate gets to low, but it's set high every time you lose a ball, so the menu doesn't look crispy while you're not playing.

BorisTheBrave wrote:
imbryk, did you use my b2ConcaveArcShape code in the end? I'm guessing not, given the level layout.
i used them everywere i could - so every concave arc is your class - thanks once again 🙂
Great game imbryk! Feels really solid.

I was wondering if you could tell us how your flippers work, especially the down movement, which is really quick.

Also how did you do the ramps (multi-layer playfield)?
Does anybody else have an idea on how to do multi-level playfields (for example ramps that go over the normal playfield)?

Original thread: https://box2d.org/forum/viewtopic.php?t=397