Hi,
I am new to corona and this is my first game.
In my “main_menu.lua” file, I want the “play_button” to transition to my “level_menu.lua”. Or the “level_menu.lua” to transition to “level_1.lua”. As for the transition, I would like to use “moveFromRight” from the director class.
Now, this is my “main_menu.lua” file:
module(..., package.seeall)
local imagelookup = require("\_imagelookup")
local animlookup = require("\_animlookup")
function newmain\_menu ()
local this = display.newGroup()
local backmenu\_4 = display.newImage(imagelookup.table["Backmenu"])
backmenu\_4.x = 320
backmenu\_4.y = 480
backmenu\_4.xScale = 1
backmenu\_4.yScale = 1
backmenu\_4.isVisible = true
--
local ui = require("ui")
local play\_button = ui.newButton{
default = imagelookup.table["Buttonplay"],
over = imagelookup.table["Buttonplayover"]
}
play\_button.x = 342.8999999999999
play\_button.y = 303.825
play\_button.isVisible = true
this:insert(play\_button)
this.play\_button = play\_button
--
local level\_menu = require("level\_menu")
local handleStartTouch = function ( event )
if (event.phase == "ended") then
local level\_menu = level\_menu:newlevel\_menu()
level\_menu:setReferencePoint(display.CenterReferencePoint)
level\_menu.x = 320
level\_menu.y = 480
level\_menu.rotation = 0
end
end
this.play\_button:addEventListener("touch", handleStartTouch)
return this
end
Now, when you press “play_button” I want it to transition using “moveFromRight” to “level_menu”
I have added “director.lua”. Also, this is the code I added to my “main.lua”
-- Import director class
local director = require("director")
-- Create a main group
local mainGroup = display.newGroup()
Also, on all the pages that I want a transition (director class), do I just add:
function new()
local localGroup = display.newGroup()
and for my image/objects:
localGroup:insert(my\_image/object)
to each one?
Also, how to I specify what transition I what for a button? (play_button)
Sorry if it’s confusing! I am new to all this!
Thanks in advance.
–
[import]uid: 15281 topic_id: 6219 reply_id: 306219[/import]