Masked puzzle games SHOWSTOPPER w/video!

I’ve been experiencing mask-related bugs for a while. And I’m sure anyone making puzzle games will end up using masks unless they want a huge file size. Since a lot of people will be making puzzle-type games, I’m gonna consider this a showstopper :slight_smile: When I started Corona I decided on a very simple game to test out the waters. Masking had problems so I went pre-cut. My app is done, but I’m back on this issue, and even made a video:

http://www.youtube.com/watch?v=4w4ThSlU2ZE

Hoping for solutions, I found Jonathan Beebe’s PuzzleApp, but when I run it on the simulator and device its sluggish and unresponsive.

http://developer.anscamobile.com/code/puzzleapp

Sorry if any of my points are outdated, my issues are with masks:

  1. Masks should exactly follow its image/group, also related to screen orientation/rotation.
  2. Masks need to have a reference point also not just center (sorry I’m not sure if it does already).
  3. It would be better if masks automatically sized itself and not be forced into 4 pixel alignment, or in the very least print a warning about it instead of crashing.
  4. Masks would be nice if it can be used as a hit area without actually masking the image. I think right now its isHitTestable, but I believe it also masks the image along with the touch events. Probably shouldn’t be called a mask anymore for that.
  5. General crashing that seem to be related to masks.

Thanks! [import]uid: 99244 topic_id: 19119 reply_id: 319119[/import]

i understand your issues with mask. but for your example you can just use a sprite. check the following code. image.png is a 512x512 image of your choice.

[lua]require “sprite”
local pieces = {}
local spriteSheet = sprite.newSpriteSheet(“image.png”, 128,128)
local spriteSet = sprite.newSpriteSet(spriteSheet, 1, 16)
for i = 1, 16 do
local sprite = sprite.newSprite(spriteSet)
sprite.currentFrame = i
table.insert(pieces,sprite)
end
--------position pieces------------------------
for i = 1, 16 do
pieces[i].x = ((i-1)%4 * 132)+64
pieces[i].y = (math.floor((i-1)/4) * 132)+64
end[/lua] [import]uid: 58777 topic_id: 19119 reply_id: 73809[/import]

I wanted to use a mask so I can cut the pieces with rounded corners. But I’m gonna keep looking for work arounds. [import]uid: 99244 topic_id: 19119 reply_id: 73820[/import]

The puzzle app was created quite a while ago (when bitmap masks first came out), so the sample was there mainly to demonstrate how to apply them, and how they *might* be used in a real-world scenario. There may also be certain incompatibilities with the current SDK as that sample was last modified probably at least two releases ago (if not more).

It’s probably not the most efficient app though because for every single puzzle piece, it’s basically a copy of the entire puzzle, just masked in a different location.

I can see why it’s giving you problems with devices. At the moment, you’ll probably have to stick with static puzzle pieces due to the performance restraints posed by having so many large images on the screens, and so many masks applied to them.

As far as the bugs go, what you’re describing may not be bugs but just limitations with our current implementation of bitmap masks.

Currently, with bitmap masks you can:

  • Place a mask on the object.

  • Determine whether you want the masked portion of the image to be able to receive touches (via the isHitTestMasked property).

  • Modify the x/y location of the mask, relative to the location of the image that’s being masked.

  • Determine the x/y scale of the mask on the image.

Some limitations include:

  • The inability to apply gradients or use setFillColor on images that are masked.

  • The alpha setting of objects that are masked cannot be changed (they’ll always appear to be at 100% opacity).

[import]uid: 52430 topic_id: 19119 reply_id: 73877[/import]

Hi Jonathan, thanks very much for your response. Four questions:

  1. Is making a puzzle game of this type (dynamic masked pieces) is no longer possible with the current version of Corona? I assume at the time you made that demo it was working fine.

  2. Whenever it becomes possible again, could you update the code for this demo?

  3. Are there any future improvements for masks? It is a basic need, but I see bigger stuff are going in front of it like multiplayer, IAPs. So I’m worried it’s going to be a while.

  4. Is isHitTestMasked fully functional? I’ve already seem some buginess. And I already know masks are not doing well being rotated. Is there a working demo of it? My next game uses a lot of this, do you recommend that I not even try this yet?

My games are for kids and nothing too fancy, so I actually moved away from Flash assuming that Corona would have this basic functionality. I hope it gets better :slight_smile:

Thanks!

[import]uid: 99244 topic_id: 19119 reply_id: 73889[/import]