Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scissor Rect for director #108

Open
MattiaFortunati opened this issue Dec 12, 2012 · 1 comment
Open

Scissor Rect for director #108

MattiaFortunati opened this issue Dec 12, 2012 · 1 comment

Comments

@MattiaFortunati
Copy link
Collaborator

RNDirector should have scissor rect for each scene (to not overlap objects from different scenes than current one)

PROBLEM: other scissorRects applied to props will override the scene one, so the overlap bug will be persistent.

@Sylph
Copy link
Contributor

Sylph commented Dec 21, 2012

For now we could also just loop through them, and move the individual scissorRects as well. It makes sense that when the screen is sliding out, the other scissorRects would move with the screen. It's what I'm doing for now.

The following in RNDirector:slideout is a rough way of how we can change it.

    if CURRENT_SCENE_GROUP ~= nil then
        local groupArray = { CURRENT_SCENE_GROUP }
        local movedScissorRectArray = {}
        local groupIndex = 1
        while groupArray[groupIndex] do
            local displayObjects = groupArray[groupIndex].displayObjects
            for i = 1, table.getn(displayObjects), 1 do
                local displayObject = groupArray[groupIndex].displayObjects[i]
                if displayObject.scissorRect and movedScissorRectArray[displayObject.scissorRect] == nil then
                    displayObject.scissorRect:moveLoc(-xx, -yy, 0, 0.001*TIME, MOAIEaseType.SMOOTH)
                    movedScissorRectArray[displayObject.scissorRect] = true
                end

                if displayObject:getType() == "RNGroup" then
                    groupArray[#groupArray+1] = displayObject
                end
            end
            groupIndex = groupIndex + 1
        end

        for i = 1, table.getn(CURRENT_SCENE_GROUP.displayObjects), 1 do
            if i == table.getn(CURRENT_SCENE_GROUP.displayObjects) then --call transition end callback only for last element
                trn:run(CURRENT_SCENE_GROUP.displayObjects[i], { type = "move", x = CURRENT_SCENE_GROUP.displayObjects[i].x - xx, y = CURRENT_SCENE_GROUP.displayObjects[i].y - yy, time = TIME, onComplete = slideEnd })
            else
                trn:run(CURRENT_SCENE_GROUP.displayObjects[i], { type = "move", x = CURRENT_SCENE_GROUP.displayObjects[i].x - xx, y = CURRENT_SCENE_GROUP.displayObjects[i].y - yy, time = TIME })
            end
        end
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants