This is a pretty Newbish question, but how can I display something over something else, even if it is displayed above the other thing in the .lua file? Thanks!
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Making Something Appear over something else
try the toFront() and toBack() apis...
cheers,
?:)
Hay Thanks!
It only half worked, I have a ball and a line coming out of the ball when you touch it. I do not want that ball to be above that ball. See below
local ball = display.newImage(_G.ballcol)
ball.x = 584
ball.y = 776
localGroup:insert(ball)
local barn = display.newImage("barn.png")
barn.x = 247
barn.y = 509
localGroup:insert(barn)
physics.addBody( barn, "static", physicsData:get("barn"))
physics.addBody (ball, { density=1, friction=.2, bounce=.5})
ball.linearDamping = 1.5
ball.angularDamping = 1.5
ball.isBullet = true
local touchhandler = display.newCircle( 10, 10, 40 )
touchhandler:setFillColor( 255, 255, 255, 0 )
touchhandler.x = ball.x
touchhandler.y = ball.y
localGroup:insert(touchhandler)
target = display.newImage( "target.png" )
target.x = ball.x; target.y = ball.y; target.alpha = 0
localGroup:insert(target)
--[[
local skipbar = display.newRect( 0, 0, 105, 20)
skipbar:setFillColor( 12, 255, 255, 1000)
skipbar.x = 245
skipbar.y = 600
localGroup:insert(skipbar)
physics.addBody (skipbar, "static", {bounce=0.2, density=1.0})
local function skip( event )
if event.phase == "began" then
timer.performWithDelay(1000, function() ball.y = 800 end )
end
end
skipbar:addEventListener( "collision", skip )
--]]
local startRotation = function()
target.rotation = target.rotation + 4
end
local function cueShot( event )
vx, vy = ball:getLinearVelocity()
if vx == 0 and vy == 0 then
local t = touchhandler
local phase = event.phase
if "began" == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
target.x = t.x
target.y = t.y
Runtime:addEventListener( "enterFrame", startRotation )
local showTarget = transition.to( target, { alpha=0.4, xScale=0.4, yScale=0.4, time=200 } )
myLine = nil
elseif t.isFocus then
if "moved" == phase then
if ( myLine ) then
myLine.parent:remove( myLine )
end
myLine = display.newLine( t.x,t.y, event.x,event.y )
myLine:setColor( 255, 255, 255, 50 )
myLine.width = 16
elseif "ended" == phase or "cancelled" == phase then
score1.text = score1.text + ("1")
audio.play(gputt)
display.getCurrentStage():setFocus( nil )
t.isFocus = false
local stopRotation = function()
Runtime:removeEventListener( "enterFrame", startRotation )
end
local hideTarget = transition.to( target, { alpha=0, xScale=1.0, yScale=1.0, time=200, onComplete=stopRotation } )
if ( myLine ) then
myLine.parent:remove( myLine )
end
-- Strike the ball!
ball:applyForce( (ball.x - event.x), (ball.y - event.y), ball.x, ball.y )
end
end
return true
end
end
touchhandler:addEventListener( "touch", cueShot )
Some of this code is from the template pool plus
when I put the above thing right below the line it doesn't put the ball above the line, but the ball does go above the barn =(
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
Subscription questions
Dynamic vs Dynamic Collision With Gravity
1.0.0.9 FXFields events
Music for Casual & Platform Games
listen for touch "began" on one object and listen for touch "ended" on another.
Can't build after registration
Happy Thanksgiving
Point object towards another objects position
Can a physics object collide with all objects in a group using local collisions?