Applying image bitmap mask for images in corona sdk application

Masking is a common practice in digital design. By using a black-and-white or a gray scaled image, you can mask your base image. This will allow you to hide or show certain portions of an image in accordance with the mask image that you are using.

In corona sdk applications, you can simply set an image mask as follows:

create the mask as:

local mask = graphics.newMask( "myMask.png" )

Then create the object:

local myImage = display.newImageRect( "myImage.png", 480, 320 )
myImage.x, myImage.y = 240,160

Then link the mask with the image as:

myImage:setMask( mask )

Its done….

How to add widget scroll view in corona sdk

You can add a scroll view in your application and add items to it as below:

local localGroup = display.newGroup()
local scrollView = widget.newScrollView{
width = 480*_w/480,
height = 320*_h/320,
scrollWidth = 0*_w/480,
scrollHeight = 0*_h/320,

local bg = display.newImageRect("bg.png",480,320)
bg.x = 240
bg.y = 160

How to disable touch on underlying sprite in corona SDK

There are 2 ways that you can disable the touch on underlying image in your corona project. Let  ‘cover‘ be the top layer and  ‘logo_1‘ be the underlying sprite.

   1)Just create a listener to cover as below and return true as follows:

function coverPressed()
          return true;

    2) Check if cover exists, and then remove the listener of logo_1 as:

logo_1:removeEventListener("tap", hidebg)

How do I attach a .txt data file saved to system.DocumentsDirectory to an email in Corona SDK

— Creating the text file —

local filePath_Type = system.pathForFile( "myTextFile.txt", system.DocumentsDirectory )
local file = filePath_Type, "r" )
if file then
  io.close( file )
  --Create an empty file--  
  local path_Type = system.pathForFile( "myTextFile.txt", system.DocumentsDirectory )
  local file = path_Type, "w+b" )
  file:write("My data inside file")
  io.close( file )

— Now, to email this file —

function showMailPicker()
  -- Create mail options --
  local options =
      to = { "",},
      subject = "Subject Text",
      body = "Email Body",
      attachment =
          { baseDir=system.DocumentsDirectory, filename="myTextFile.txt", type="text" },

   -- Send mail --
  native.showPopup("mail", options)

submitButton = display.newImageRect("myButton.png",100,40)
submitButton.x = 160
submitButton.y = 240