Animated Menu Button for Corona SDK (hamburger style)

Get it from the Corona Marketplace here

animated hamburger menu button

Overview

Creates an animated hamburger style menu button that transforms into an 'X' close button on tap.

Syntax

createMenuButton( grp, xpos, ypos, color, lineWidth, lineHeight )

This function accepts the following parameters:

grp

Display Group. The display group you wish to insert the button into.

xpos

Number. The x position of the button.

ypos

Number. The y position of the button.

color (optional)

Table. A table of color values in the format {r,g,b,a}. Default color is black.

lineWidth (optional)

Number. The width of each line in the hamburger style button. Default is 36.

lineHeight (optional)

Number. The height of each line in the hamburger style button. Default is 5.

Methods

object:removeButton()

Removes the button and frees its memory, assuming there are no other references to it.
Note: You can also just remove the group you inserted the button in.

How To Use

Important: Place the class_AnimatedMenuButton.lua file inside your project folder

--Require the AnimatedMenuButton class local classMenuButton = require('class_AnimatedMenuButton')   --Create a black menu button in top left corner at default size local menuButton = classMenuButton.createMenuButton( buttonGroup, 30, 25 )   --Create the function to show your menu or page function menuButton:onShow() --Your code here composer.showOverlay( "menu" ) end   --Create the function to hide your menu or page function menuButton:onHide() --Your code here composer.hideOverlay( "fade", 400 ) end

Use the parameters to create a smaller blue menu button:

--createMenuButton( grp, xpos, ypos, color, lineWidth, lineHeight ) local menuButton = classMenuButton.createMenuButton( sceneGroup, 30, 25, {0, 0, 1}, 26, 4 )

Copyright 2017 Noah Malewicz