Scrolling group on Runtime works different than in CreateScene (Storyboard)

Hello Everyone !

Im facing a weird problem. Im making a game that requires scrolling a background. But the scrolling ( by changing group.y ) behaves different in Runtime and CreateScene. Here is an example.

[lua]…
local bg, gameGroup

local function scroll()
gameGroup.y = 0
end

– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
gameGroup = group

bg = display.newImage(“bg.png”)
bg:setReferencePoint(display.BottomLeftReferencePoint)
bg.x = 0 bg.y = _H

group:insert(bg)

– God method
scroll()

end

– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view

– Bad One :slight_smile:
–Runtime:addEventListener(“enterFrame”, scroll)

– INSERT code here (e.g. start timers, load audio, start listeners, etc.)

end[/lua]

When I run scroll via Runtime, position of my group varies from image size, and its never on bottom. Im using 320 x 1920 image.

When I call scroll() Its ok, bottom of my image is on the bottom of the screen so in _H.

Any ideas what am I doing wrong ? Ive tried billions things, and my head is burning.

Best regards!

[import]uid: 77868 topic_id: 19931 reply_id: 319931[/import]

Got it, moved gameGroup = group to enterScene :smiley: [import]uid: 77868 topic_id: 19931 reply_id: 77550[/import]

Hello!

Try moving the:

gameGroup = group

from the createScene to enterFrame. It should do the job!

Keep coding! :slight_smile:
Mike [import]uid: 77763 topic_id: 19931 reply_id: 77551[/import]

Nooo, my fault :smiley: Its still wrong, I had an error and I thought its ok, but its not. Any ideas ?

EDIT

print(gameGroup.y) after Runtime shows -544 and print(group.y) withoutit = 0 so with these numbers I can use a workaround and make both 0. But still not the best solution :slight_smile: [import]uid: 77868 topic_id: 19931 reply_id: 77632[/import]