Is there a way to dynamically change the bitmap mask?

Hello Everyone,

I have a game idea that would require the user to scrub a scene to reveal an image behind it.

Basically I have two images and I want to scrub the old image to reveal the new image.

I was thinking there might be a way to poke brush sized holes into a mask or alpha channel, but I’m stuck.

Anyone have any suggestions? or is this going to be an impossible task for Corona?

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 336214[/import]

Nope, this is doable - classic question by the way.

The trick is to reverse your way of thinking.

  1. You put the first image you see in the back.
  2. Then everything a user touches the screen, you put a sprite of the new image on top of the old image, with a mask of a brush stroke just where the user touches.

This will make the new image appear only where a user touches. [import]uid: 70134 topic_id: 36214 reply_id: 143879[/import]

Brilliant! I never thought of doing it like that. I would figure it would be bad to have that many sprints on the screen, but I could probably put in some error checking so it doesn’t overlap much. I’ll give it a try.

Do you know of any demo code that is similar to what I’m trying to achieve? I’m fairly new to Corona and LUA, but I’m picking it up pretty fast.

Thanks again for you help!,

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 143942[/import]

Hi Ryan,

No demo code, but it should be fairly straightforward, and I have seen this question asked before on the forum so maybe you could dig around.

As far as the number of sprites on the screen, I guess your best approach would be to calculate the distance from the last touchpoint and only “draw” if the new touchpoint is far enough from the last. Good luck, and let me know if you really really can’t figure it out!

Cheers,
Thomas [import]uid: 70134 topic_id: 36214 reply_id: 143944[/import]

Roger. I’ll start hacking away at it tonight. If I run into any issues I will post my code for review.

Thanks again,

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 143946[/import]

Nope, this is doable - classic question by the way.

The trick is to reverse your way of thinking.

  1. You put the first image you see in the back.
  2. Then everything a user touches the screen, you put a sprite of the new image on top of the old image, with a mask of a brush stroke just where the user touches.

This will make the new image appear only where a user touches. [import]uid: 70134 topic_id: 36214 reply_id: 143879[/import]

Brilliant! I never thought of doing it like that. I would figure it would be bad to have that many sprints on the screen, but I could probably put in some error checking so it doesn’t overlap much. I’ll give it a try.

Do you know of any demo code that is similar to what I’m trying to achieve? I’m fairly new to Corona and LUA, but I’m picking it up pretty fast.

Thanks again for you help!,

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 143942[/import]

Hi Ryan,

No demo code, but it should be fairly straightforward, and I have seen this question asked before on the forum so maybe you could dig around.

As far as the number of sprites on the screen, I guess your best approach would be to calculate the distance from the last touchpoint and only “draw” if the new touchpoint is far enough from the last. Good luck, and let me know if you really really can’t figure it out!

Cheers,
Thomas [import]uid: 70134 topic_id: 36214 reply_id: 143944[/import]

Roger. I’ll start hacking away at it tonight. If I run into any issues I will post my code for review.

Thanks again,

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 143946[/import]

Nope, this is doable - classic question by the way.

The trick is to reverse your way of thinking.

  1. You put the first image you see in the back.
  2. Then everything a user touches the screen, you put a sprite of the new image on top of the old image, with a mask of a brush stroke just where the user touches.

This will make the new image appear only where a user touches. [import]uid: 70134 topic_id: 36214 reply_id: 143879[/import]

Brilliant! I never thought of doing it like that. I would figure it would be bad to have that many sprints on the screen, but I could probably put in some error checking so it doesn’t overlap much. I’ll give it a try.

Do you know of any demo code that is similar to what I’m trying to achieve? I’m fairly new to Corona and LUA, but I’m picking it up pretty fast.

Thanks again for you help!,

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 143942[/import]

Hi Ryan,

No demo code, but it should be fairly straightforward, and I have seen this question asked before on the forum so maybe you could dig around.

As far as the number of sprites on the screen, I guess your best approach would be to calculate the distance from the last touchpoint and only “draw” if the new touchpoint is far enough from the last. Good luck, and let me know if you really really can’t figure it out!

Cheers,
Thomas [import]uid: 70134 topic_id: 36214 reply_id: 143944[/import]

Roger. I’ll start hacking away at it tonight. If I run into any issues I will post my code for review.

Thanks again,

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 143946[/import]

Nope, this is doable - classic question by the way.

The trick is to reverse your way of thinking.

  1. You put the first image you see in the back.
  2. Then everything a user touches the screen, you put a sprite of the new image on top of the old image, with a mask of a brush stroke just where the user touches.

This will make the new image appear only where a user touches. [import]uid: 70134 topic_id: 36214 reply_id: 143879[/import]

Brilliant! I never thought of doing it like that. I would figure it would be bad to have that many sprints on the screen, but I could probably put in some error checking so it doesn’t overlap much. I’ll give it a try.

Do you know of any demo code that is similar to what I’m trying to achieve? I’m fairly new to Corona and LUA, but I’m picking it up pretty fast.

Thanks again for you help!,

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 143942[/import]

Hi Ryan,

No demo code, but it should be fairly straightforward, and I have seen this question asked before on the forum so maybe you could dig around.

As far as the number of sprites on the screen, I guess your best approach would be to calculate the distance from the last touchpoint and only “draw” if the new touchpoint is far enough from the last. Good luck, and let me know if you really really can’t figure it out!

Cheers,
Thomas [import]uid: 70134 topic_id: 36214 reply_id: 143944[/import]

Roger. I’ll start hacking away at it tonight. If I run into any issues I will post my code for review.

Thanks again,

-Ryan [import]uid: 190934 topic_id: 36214 reply_id: 143946[/import]