Can somebody help me with this also. This code was working great for me and now all I get is a black screen. I basically have a titescreen with some blocks falling, that I want to be able to drag. It was working on one of the blocks and now all I get is a blank screen and I don’t know what I did. This is the code I have.
module(…, package.seeall)
function new()
local localGroup = display.newGroup()
–> This is how we start every single file or “screen” in our folder, except for main.lua
– and director.lua
–> director.lua is NEVER modified, while only one line in main.lua changes, described in that file
local physics = require(“physics”)
physics.start()
local background = display.newImage (“title2.png”)
background.x = 240
–> This sets the background
local instructions = display.newImage (“instructions.png”)
instructions.x = 100
instructions.y = 240
instructions.xScale = .5
instructions.yScale = .5
local highscores = display.newImage (“highscores.png”)
highscores.x = 380
highscores.y = 240
highscores.xScale = .5
highscores.yScale = .5
local floor = display.newImage(“floor.png”)
floor.x = 230
floor.y = 360
physics.addBody( floor, “static”, { friction=0.5, bounce=0.3 } )
local redblock = display.newImage( “redblock.png” )
redblock.x = 350
redblock.y = 50
redblock.rotation = 5
redblock.xScale = .5
redblock.yScale = .5
physics.addBody( redblock, { density=2.0, friction=0.5, bounce= 0.5 } )
local function startDrag( event )
local phase = event.phase
if “began” == phase then
– Store initial position
x0 = event.x
y0 = event.y
redblockx0 = redblock.x
redblocky0 = redblock.y
print(x0, y0)
– Stop current motion, if any
redblock:setLinearVelocity( 0, 0 )
redblock.angularVelocity = 0
elseif “moved” == phase or “ended” == phase or “cancelled” == phase then
redblock.x = ballx0 + event.x - x0
redblock.y = bally0 + event.y - y0
end
– Stop further propagation of touch event!
return true
end
Runtime:addEventListener( “touch”, startDrag ) [import]uid: 72372 topic_id: 11706 reply_id: 44040[/import]