Book Story

Hi,

I am creating comic story using director book framework and want to store the recent id in sandbox file.

But I am facing problem in storing recent id because the framework is loading three pages at a time i.e previous, current and next and when i am storing it. It’s store next id. When there is last last page it’s store 1st id.

So, how can i get current id or page ?

Any help will be appreciated.

Thanks,.

I’m not sure on Director, but if you use Corona’s native storyboard API, you can call command

[lua]local current = storyboard.getCurrentSceneName()[/lua]

Thanks Crafty,

I know about the storybook API. But I want to stick with director because I have already implemented my code using this API.

If I go through the storybook API then I need to rewrite my code.

There might be some solution or way in director library to find out the current scene name.

Thanks,

Hmm… Maybe have a global variable declared when the app runs and update it at the start of every scene? 

Hi,

I have fixed the above issued and now want to know that,

Is there any way to detect multi-touch and simple touch on same object.

Because I want to assign different functionality on both the touch(single touch, multi-touch) event.

In my project, I have assigned page flip or swipe method using director book framework on touch event and I also want to do pinch zoom on same object on multi-touch or when user touches with two fingers. 

I’m stuck now for couple of days. 

Any help will be appreciated.

I am using this code for multi-touch but unable to get the number of touches > 2.

Is I am doing something wrong? 

<lua>

function bookBackground:touch( event )

    if event.phase == “began” then

    print(“in began phase”…self.numTouches )

        display.getCurrentStage():setFocus( self, event.id )

        self.numTouches = self.numTouches + 1

        if self.numTouches >= 2 then

            print( “This object is being multi-touched.” )

        end

    elseif event.phase == “cancelled” or event.phase == “ended” then

        self.numTouches = self.numTouches - 1

        if self.numTouches <= 0 then

            display.getCurrentStage():setFocus( nil )

        end

    end

    return true

end



       

        local bookBackground = display.newRect( 0, 0, _W, _H )

        bookBackground.alpha = 0.01

        bookBackground:addEventListener( “touch”, moveBookPage )

        currView:insert( bookBackground )

        bookBackground.numTouches = 0

        bookBackground:addEventListener( “touch”, bookBackground )

</lua>

Thanks,

I’m not sure on Director, but if you use Corona’s native storyboard API, you can call command

[lua]local current = storyboard.getCurrentSceneName()[/lua]

Thanks Crafty,

I know about the storybook API. But I want to stick with director because I have already implemented my code using this API.

If I go through the storybook API then I need to rewrite my code.

There might be some solution or way in director library to find out the current scene name.

Thanks,

Hmm… Maybe have a global variable declared when the app runs and update it at the start of every scene? 

Hi,

I have fixed the above issued and now want to know that,

Is there any way to detect multi-touch and simple touch on same object.

Because I want to assign different functionality on both the touch(single touch, multi-touch) event.

In my project, I have assigned page flip or swipe method using director book framework on touch event and I also want to do pinch zoom on same object on multi-touch or when user touches with two fingers. 

I’m stuck now for couple of days. 

Any help will be appreciated.

I am using this code for multi-touch but unable to get the number of touches > 2.

Is I am doing something wrong? 

<lua>

function bookBackground:touch( event )

    if event.phase == “began” then

    print(“in began phase”…self.numTouches )

        display.getCurrentStage():setFocus( self, event.id )

        self.numTouches = self.numTouches + 1

        if self.numTouches >= 2 then

            print( “This object is being multi-touched.” )

        end

    elseif event.phase == “cancelled” or event.phase == “ended” then

        self.numTouches = self.numTouches - 1

        if self.numTouches <= 0 then

            display.getCurrentStage():setFocus( nil )

        end

    end

    return true

end



       

        local bookBackground = display.newRect( 0, 0, _W, _H )

        bookBackground.alpha = 0.01

        bookBackground:addEventListener( “touch”, moveBookPage )

        currView:insert( bookBackground )

        bookBackground.numTouches = 0

        bookBackground:addEventListener( “touch”, bookBackground )

</lua>

Thanks,