Well done - so it is a normal LUA behavior then but I can’t figure it out…
Below is the block of code I am trying to run, and I am using storyboard - I don’t know if this has something to do with it.
Look at line 87 and 88 - theres where I try to remove the listener. The listener is created at line 217 and 218, and the function is at 170 and 183.
-- Called when the scene's view does not exist:
function scene:createScene( event )
-----------------------------------------------------------------------------
-- CREATE display objects and add them to 'group' here.
-- Example use-case: Restore 'group' from previously saved state.
-----------------------------------------------------------------------------
local group = self.view
require "LevelHelperLoader"
application.LevelHelperSettings.directorGroup = group
loader = LevelHelperLoader:initWithContentOfFile("safari.plhs")
loader:instantiateSprites()
local myParallax = loader:parallaxNodeWithUniqueName("parallax")
local myClouds = loader:parallaxNodeWithUniqueName("clouds")
local sign\_right = loader:spriteWithUniqueName("NEXT")
local sign\_left = loader:spriteWithUniqueName("PREV")
sign\_left.alpha = 0
--Get Jimmy
local Jimmy = loader:spriteWithUniqueName("jimmy")
Jimmy.alpha = 0
local hold = function()
transition.to(Jimmy,{alpha=1,time=1000})
end
timer.performWithDelay(4000, hold,1)
local function openGallery( event )
if event.phase =="began" then
display.getCurrentStage():setFocus( btnPO )
elseif event.phase == "ended" then
display.getCurrentStage():setFocus(nil)
--group.isVisible = false;
parentsOnly.showGallery()
--transition.to(group,{alpha=0,time=500})
return true;
end
end;
loader:spriteWithUniqueName("ALBUM"):addEventListener("touch",openGallery)
-- Knyt alla böcker till samma eventListener
--local spritesWithTag = loader:spritesWithTag(LevelHelper\_TAG.DOWNLOAD)
--for i = 1, #spritesWithTag do
-- local mySprite = spritesWithTag[i];
-- mySprite:alpha=1
--end
-- PO Button
-- Dummy line for alignment
--local myLine = display.newImage("assets/line.png",screenW/2-3,10);
--myLine:setReferencePoint( display.TopCenterReferencePoint );
local btnPO = display.newImage("assets/GUI\_POLock\_gray.png",screenW-40,10)
btnPO.alpha = 0
group:insert(btnPO)
transition.to(btnPO,{alpha=1,time=1000})
local function openPO( event )
if event.phase =="began" then
display.getCurrentStage():setFocus( btnPO )
elseif event.phase == "ended" then
display.getCurrentStage():setFocus(nil)
leftRect:removeEventListener("touch",prevAnimal)
rightRect:removeEventListener("touch",nextAnimal)
myParallax:setPaused(true)
myClouds:setPaused(true);
group.isVisible = false;
parentsOnly.showLock()
local tablesetup = [[UPDATE gamedata set opened = 1;]];
db:exec( tablesetup );
return true;
end
end;
btnPO:addEventListener("touch",openPO);
local function checkSigns( value )
if value \> 1 then
transition.to(sign\_left,{alpha=1,300})
elseif value == 1 then
transition.to(sign\_left,{alpha=0,300})
end
if value == maxAnimal then
transition.to(sign\_right,{alpha=0,300})
elseif value \> 2 then
transition.to(sign\_right,{alpha=1,300})
end
end
local function stepLeft()
local i = 0
--Movement control
local function easeIn()
i = i + 1;
myParallax.position.x = myParallax.position.x - (i\*13/2);
if i == 22 then
local function easeOut()
i = i - 1
myParallax.position.x = myParallax.position.x - (i\*13/2);
if(i==0) then
isMoving = false;
--print(myParallax.position.x, animal)
end
end
timer.performWithDelay(10, easeOut,22)
end
end
timer.performWithDelay(10, easeIn,22)
--End movement control
end
local function stepRight()
local i = 0;
-- Movemment control of Parallax
local function easeIn()
i = i + 1;
myParallax.position.x = myParallax.position.x + (i\*13/2);
if i == 22 then
local function easeOut()
i = i - 1
myParallax.position.x = myParallax.position.x + (i\*13/2);
if(i==0) then
isMoving = false;
end
end
timer.performWithDelay(10, easeOut,22)
end
end
timer.performWithDelay(10, easeIn,22)
--End movement controll of parallax
end
--local function monkey2(event)
local function nextAnimal( event )
if event.phase == "ended" then
if isMoving == false then
isMoving = true;
animal = animal + 1
checkSigns(animal);
stepLeft();
end
end
end
local function prevAnimal( event )
if event.phase=="ended" then
if isMoving == false then
isMoving = true;
animal = animal - 1
checkSigns(animal);
stepRight();
end
end
end
--Add eventlisteners for the buttons
sign\_right:addEventListener("touch",nextAnimal)
sign\_left:addEventListener("touch", prevAnimal)
--===================================================================
--Osynliga rektanglar för snabb navigering
--===================================================================
--Vänster rektangel
leftRect = display.newRect(0,0, 100, 768)
leftRect.alpha = 0
leftRect.isHitTestable = true
--Höger rektangel
rightRect = display.newRect(924,0, 100, 768)
rightRect.alpha = 0
rightRect.isHitTestable = true
leftRect:addEventListener("touch",prevAnimal)
rightRect:addEventListener("touch",nextAnimal)
local function moveScene( event)
if(event.phase=="began") then
x0 = event.x
end
if(event.phase=="moved") then
if(x0-event.x\>200 or x0-event.x \< -200 and animal \> 0) then
if(x0 \< event.x) then
if isMoving==false and animal \> 1 then
animal = animal - 1
checkSigns(animal);
isMoving=true;
stepRight();
end
else
if isMoving==false and animal \< maxAnimal then
animal = animal + 1
checkSigns(animal);
isMoving=true;
stepLeft();
end
end
end
end
end
Runtime:addEventListener("touch", moveScene)
-- Funktion från alla små fönster i PO att sätta tillbaka synligheten på spelet...
local function reSet()
group.isVisible=true;
myParallax:setPaused(false)
myClouds:setPaused(false);
--transition.to(group,{alpha=1,time=100})
end
master.reSet = reSet;
local function moveParallax(position, step)
myParallax.position.x = position
animal = step
checkSigns(step)
end
master.moveParallax = moveParallax;
parentsOnly.setTarget(master);
end
Best regards, Joakim
[/code] [import]uid: 81188 topic_id: 22029 reply_id: 87645[/import]