To do this in the right way I do a new EFFECT(Prev and Next Curl Page) at function director:changeScene. But only 50% is working, the next, so I need help with the prev EFFECT that is the other 50%.
Like this one that is part of Director Class:
– EFFECT: Over From Bottom
elseif effect == “overFromBottom” then
nextView.x = 0
nextView.y = _H
showFx = transition.to( nextView, { y = 0, time = fxTime, onComplete = fxEnded } )
I made another elseif effect for the page curl to go next and I`m having problems with the prev effect. Lets start with the code:
PS: This pageturn-big.png and mask_1024x768.png is given at Jonathan Beebe tutorial http://tinyurl.com/7d4z4uw
Line1210 (director.lua)
– EFFECT: Next Curl Page (iPad Landscape)
elseif effect == “curlPageNext” then
– Reseting effectView group if it is diferent of 0
while (effectView.numChildren ~= 0) do
effectView:remove( 1 )
–print(“effectView was RESETED”)
end
–Correcting the pos
nextView.x = 0
–Adding the current page to the effect mask group
effectView:insert(currView);
–
local curlPage = display.newImageRect( “img/pageturn-big.png”, display.contentWidth, display.contentHeight )
curlPage.x, curlPage.y = display.contentWidth*0.5, display.contentHeight*0.5
curlPage.isVisible = false
effectView:insert( curlPage )
– mask should match dimensions of content (e.g. content width/height)
local curlMask = graphics.newMask( “img/mask_1024x768.png” ) – iPad landscape
effectView:setMask( curlMask )
– set initial mask position
effectView.maskX = display.contentWidth * 0.5+100
effectView.maskY = display.contentHeight * 0.5
– prepare the page-to-be-turned and the curl image
currView:setReferencePoint( display.BottomRightReferencePoint )
curlPage:setReferencePoint( display.BottomRightReferencePoint )
curlPage.rotation = 35
curlPage.x = display.contentWidth + (display.contentWidth*0.10)+ 400
curlPage.y = display.contentHeight + (display.contentHeight*0.25) + 300
curlPage.isVisible = true
– show pagecurl animation and transition away (next page should already be in position)
transition.to( effectView, { maskX=-display.contentWidth*0.75, time=fxTime } )
transition.to( curlPage, { rotation=0, x=0, y=display.contentHeight - 50, time=fxTime, onComplete=fxEnded } )
curlPage.yScale = curlPage.y * 0.2
This up code is the effect and is working awsome with Scenes, not only with images like Beebe made. Although when I tryed the previews effect only some parts, the new text from previus page appear but background and bottom menu doesn`t appeared at transition animation.
Now I will show what I tryed and fail at the – EFFECT: Prev Curl Page (iPad Landscape) --, other 50% of the curl page in director project.
Line1257 (director.lua)
– EFFECT: Prev Curl Page
elseif effect == “curlPagePrev” then
–Pos the nextView that begins at x = 1024
nextView.x = 0
print(nextView.numChildren)
effectView:insert(nextView)
–
local curlPage = display.newImageRect( “img/pageturn-big.png”, display.contentWidth, display.contentHeight )
effectView:insert(curlPage)
–
local curlMask = graphics.newMask( “img/mask_1024x768.png” ) – iPad landscape
effectView:setMask( curlMask )
effectView.maskX = -1024
effectView.maskScaleY = 2
curlPage.y = curlPage.y + 320
curlPage.x = curlPage.x - 1512
curlPage.yScale = 1.4
curlPage.rotation = 35
curlPage.isVisible = true
local hideCurl = function()
print(curlPage.x)
curlPage.isVisible = false
effectView:setMask( nil )
print(nextView.numChildren)
fxEnded()
end
transition.to( effectView, { maskX = 1024, time=fxTime } )
transition.to( curlPage, { rotation = 10, x=display.contentWidth+(display.contentWidth*0.70), time=fxTime, onComplete=hideCurl })
The problem is:
The first object that you insert at localGroup of the first page (nextView in prev code). This object doesn`t apear in the transition effect.
So only if I put the objVanish before the backgroud like:
__________________________________________________________________________________________
(page1.lua)
function new()
local localGroup = display.newGroup()
local objVanish = display.newRect( 1, 1, 1, 1 )
localGroup:insert(objVanish)
bg = criarObj.addObj(“img/livro/Pag-1.jpg”, _W/2, _H/2, 1);
localGroup:insert(bg)
…
return localGroup
end
__________________________________________________________________________________________
Only with this will work.
Someone Know why?
Code available for download = http://www.artreze.com/code/CurlDirectorFx.zip
Thank you Jonathan Beebe by the “How to Create a Page Curl in Corona” tutorial and Rauber Labs by the director class. [import]uid: 88034 topic_id: 21270 reply_id: 321270[/import]