huge problems with code

I’ve been developing with corona sdk on windows. I got a mac recently and migrated everything to that OS.
Now things don’t work as they did in windows.
For example, i used to apply a mask to an image in order to get a specific shape. It worked fine, but now in mac, the borders of the image show up (the should be masked out), and the shape isn’t exactly the same as it did before.
Other problem. I used a button to change the color of a specific object in the game, it worked fine too on windows. Now, whenever i press that button, the whole screen gets filled with that color (if i press the blue button, the screen turns blue). That’s a display.newRect that is not getting drawn inside its limits.
I don’t understand how this things work properly on windows and now everything is just useless.
How come that the code is not interpreted the same way? And what’s more, i don’t know how to do thsi things now because results are nonsense.
Should i rewrite everything now that i’m am working on mac?
Isn’t corona supposed to be cross-platform? I’m not criticizing corona, i just don’t get it. [import]uid: 98755 topic_id: 17466 reply_id: 317466[/import]

If you code things correctly then they should look the same on Windows / Mac / iPhone

Without seeing any of your code its impossible to say where you are going wrong.

Are your config files setup for android only? [import]uid: 5354 topic_id: 17466 reply_id: 66263[/import]

Corona uses core code that is common to all platforms and platform-specific code for Mac, Windows, iOS and Android. I would think the features you are using would be core code and work the same across all platforms.

Post code here in the forum so we can take a look.

Otherwise, for troubleshooting user code, please see http://www.anscamobile.com/corona/support/?ref=nav
Thanks,
Tom [import]uid: 7559 topic_id: 17466 reply_id: 66269[/import]

There is a bug in Corona for Mac and iOS where if your mask image’s width in pixels is not a multiple 4, then you’ll get some weird artifacting onscreen. You can work-around this issue by increasing the width of your image to the next multiple of 4. Please note that you only have to do this with image masks. You don’t have to do this with normal images.

Here’s a more detailed explanation. This is an image “stride” issue where OpenGL wants to pack rows of pixels into 4 bytes (at least on the platforms we support), so it expects the image width to be a multiple of 4. Corona for Windows and Android automatically compensates for this by padding the right side of the image in memory with extra alpha pixels, forcing the width to be a multiple of 4 pixels. Corona for Mac and iOS do not do this at the moment.
[import]uid: 32256 topic_id: 17466 reply_id: 66303[/import]

First of all, thanks everybody for your replies. Problem was what Tom wrote. I had no idea that i was supposed to work with multiple 4. Is it something usual or just specific to Corona? Cause it would be great to include this in the mask section of the API reference, so that other beginners like me don’t get stuck in this.
Still having some other problems but they might be a result of my inexperienced programming skills. If i can’t get it solved i’ll do what you guys recommended.
Thanks again! [import]uid: 98755 topic_id: 17466 reply_id: 66427[/import]

This is from the graphics.newMask( ) API page:
https://developer.anscamobile.com/node/5248

Note: Bit Mask Requirements

  1. The mask image width and height must be multiples of 4.
  2. The mask image must have a black border around the mast that is 3 or more pixels. [import]uid: 7559 topic_id: 17466 reply_id: 66518[/import]

My question regarding newMask() - does #1 mean the original image (sans border) must be a multiple of 4? Or the entire thing combined?

Seemed odd to ask for multiple of four and then give a minimum border that wasn’t a 4 multiple… [import]uid: 41884 topic_id: 17466 reply_id: 66543[/import]

The image width in pixels MUST be a multiple of 4… and it must contain the border width required. So if the image isn’t big enough to meet the border requirement, then you must keep adding 4 more pixels to the width until it does. Does that make sense? [import]uid: 32256 topic_id: 17466 reply_id: 66547[/import]

Then I should apologize. I had absolutely skipped the notes. Pretty stupid of me. Thanks again for your help :slight_smile: [import]uid: 98755 topic_id: 17466 reply_id: 66551[/import]

No need to apologize. :slight_smile:
Image masking is a more advanced feature, so I can understand if it gives people a bit of trouble. Especially since the Windows version of Corona is much more lenient about the image mask constraints when compared to the Mac version.

If it helps you any, have a look at sample apps “Graphics\Flashlight” and “Graphics\X-ray” that is included with the Corona SDK for examples on how to set up image masks. [import]uid: 32256 topic_id: 17466 reply_id: 66552[/import]

Josh, the only thing I was trying to clear up is that “mask image width” is not necessarily “png file image width”, if you get what I’m saying?

It would be perfectly understandable to misinterpret what you’re saying as “the image inside the border needs to be a factor of 4” as opposed to “the entire canvas”, specifically because you don’t mention a factor of four for the border.

I think we more or less have an understanding now though. :slight_smile:

[import]uid: 41884 topic_id: 17466 reply_id: 66554[/import]

*thumbs up* :slight_smile: [import]uid: 32256 topic_id: 17466 reply_id: 66557[/import]