Hi all,
I’ve been working my way through the various Tutorials as hard and as fast as I can… I’ve just found a bit of script that uses some clever masking, to produce a nice page curl effect (posted in the Corona script library by dedoubleyou1).
I thought, as with all books, that it would be nice to make use of a ‘Contents’ page, allowing the reader to use a navigation/menu element to jump from Chapter to chapter.
So I used the basic demo provided with Director class as a starting point, you probably know the one I’m talking about, - Red, Green and Blue buttons.
The problem I’ve had is twofold. I can call the ‘Flipbook’ script into the ‘scene’, no problem, but because it uses an array for it’s subsequent pages, I’m not sure what syntax to use to include the element into my local group. Console gives the error: “bad argument #-2 to ‘insert’ (Proxy expected, got nil)”
…Because of this, my ‘back button’ doesn’t show.
Here’s the code
[lua]module(…, package.seeall)
function new()
local localGroup = display.newGroup()
local Flipbook = require ‘flipbook’
local background = display.newImage (“redbackground.png”)
localGroup:insert(background)
–> background
local myFirstFlipbook = Flipbook:newFlipbook(“background_back.png”, “mainshadow.png”, “newshadow.png”, “curlshadow.png” )
myFirstFlipbook:addPage( “backgroundA.png” )
myFirstFlipbook:addPage( “backgroundB.png” )
myFirstFlipbook:addPage( “backgroundC.png” )
localGroup:insert(myFirstFlipbook)
–> ******Page curl reference******
local backbutton = display.newImage (“backbutton.png”)
backbutton.x = 160
backbutton.y = 350
localGroup:insert(backbutton)
–> “back” button
local function pressBack (event)
if event.phase == “ended” then
director:changeScene (“menu”)
end
end
backbutton:addEventListener (“touch”, pressBack)
–> function and listener to the “back” button
return localGroup
end[/lua]
I realise, at some point, I’ll have to create a different display group for the book-element and add a true return value to the button (to stop touch events happening ‘through’ the button), but for now, it would be nice just to see the pagecurl and button, stacked in the right order and working ‘locally’
Any help will greatly appreciated.
Mark
[import]uid: 176868 topic_id: 31961 reply_id: 331961[/import]