Ok, I got my code back to how it was. Here it is:
storyboard = require( "storyboard" )
scene = storyboard.newScene()
sprite = require "sprite"
movieclip=require ("movieclip")
ui = require( "ui" )
physics = require "physics"
physics.start()
physics.setGravity( 0,12 )
function scene:createScene( event )
local group = self.view
local myRect=display.newRect(0,0,1,1)
myRect.alpha=0
group:insert(myRect)
end
function scene:enterScene( event )
local group = self.view
veryback=display.newGroup()
back=display.newGroup()
itemsBox=display.newGroup() --Itemsbox group
front=display.newGroup()
front:insert(itemsBox)
game=display.newGroup() --Master Group, for camera scrolling
local height=display.contentHeight
local width=display.contentWidth
local middleY = display.contentHeight/2
local middleX = display.contentWidth/2 --alignment
local farBorderLeft=display.newRect(0, 0, 10, 768)
farBorderLeft:setFillColor ( 0, 0, 0 )
farBorderLeft.x=-7
physics.addBody ( farBorderLeft, "static", {density=1, friction=1, bounce=0.3})
local farBorderRight=display.newRect(0, 0, 10, 768)
farBorderRight:setFillColor ( 0, 0, 0 )
farBorderRight.x=2055
physics.addBody ( farBorderRight, "static", {density=1, friction=1, bounce=0.3})
game:insert(farBorderLeft)
game:insert(farBorderRight)
local level=display.newRect(0,0,2048,768)
level.x, level.y=1024, 384
level:setFillColor(0,0,0)
game:insert( level )
local ground=display.newRect(0,0,2048,10)
physics.addBody ( ground, "static", {bounce=0.1, friction=35})
ground.x, ground.y=1024, 700
ground.alpha=1
game:insert(ground)
local tile=display.newRect(0,0,95,95)
tile:setFillColor(255,0,0)
tile.x, tile.y=51.5,51.5
game:insert(tile)
function moveMe(event)
phase=event.phase
t=event.target
if "began"==phase then
display.getCurrentStage ( ):setFocus(t)
t.isFocus=true
elseif t.isFocus then
if "moved"==phase then
t.x, t.y=event.x, event.y
elseif "ended"==phase or "cancelled"==phase then
display.getCurrentStage ( ):setFocus(nil)
t.isFocus=false
if event.y\>119 then --start of alignment function
game:insert(t) --put it into the camera scrolling group
elseif event.y\<120 then
itemsBox:insert(t) --put it in the items box so that it won't scroll
--transition.to(t, {x=51.5, y=51.5, time=75 } ) (for animation, so it doesn't look so jerky
t.x, t.y=51.5, 51.5
end
end
end
end
tile:addEventListener("touch", moveMe)
local player=display.newCircle(0,0,90)
player.x, player.y=middleX, middleY
physics.addBody(player, {radius=90, friction=35})
game:insert(player)
player.angularVelocity=500
local function moveCamera()
if (player.x \> 512 and player.x \< 1536) then
game.x = -player.x + 512
end
end
Runtime:addEventListener( "enterFrame", moveCamera )
end
function scene:exitScene( event )
local group = self.view
end
function scene:destroyScene( event )
local group = self.view
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )
return scene
Now, that should be exactly what everyone said to do. However, it does exactly the same thing if you uncomment the transition and comment the flat x and y setting: the tile hides! Why? Help would REALLY be appreciated. As a side note: You can see it best if instead of circles and rectangles you use images. For example, you can see the ball spin and the ground pass by, etc… [import]uid: 147322 topic_id: 27068 reply_id: 110567[/import]