Hey dark Console!! Can you help me figure out how I can tell the program to only dispatch the dispatcher when the hands are inside the hit spot that I have created? Heres the code that I have so far
[lua]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR
– LOAD PARTICLE LIB
local loqsprite = require(‘loq_sprite’)
local physics = require (“physics”)
local director = require(“director”)
physics.start()
physics.setGravity(0,0)
local rand = math.random
local moveSpeed = 4000
local screenW = display.contentWidth
local screenH = display.contentHeight
local BG = display.newImageRect(“background.png”, 1024, 768)
BG.x = screenW/2; BG.y = screenH/2
local gfactory = loqsprite.newFactory(‘girl’)
local girl = gfactory:newSpriteGroup()
girl.x = 508; girl.y = 443
local wfactory = loqsprite.newFactory(‘water’)
local water = wfactory:newSpriteGroup()
water.x = 300; water.y = 310
water.alpha = 0
local hfactory = loqsprite.newFactory(‘hands’)
local hands = hfactory:newSpriteGroup()
hands.x =130; hands.y = 460
physics.addBody (hands, {radius = sensorRect, isSensor = true})
hands.myName = “hands”
atrace(xinspect(hands:getSpriteNames()))
function moveLeft()
transition.to(hands, {time=moveSpeed, x = 130, y = hands.y, onComplete = moveRight})
end
function moveRight()
transition.to(hands, {time=moveSpeed, x = 870, y = hands.y, onComplete = moveLeft})
end
local hitSpot = display.newImageRect(“hitSpot.png”, 240, 150)
hitSpot.x = 510; hitSpot.y = 555
hitSpot.alpha = 0
physics.addBody (hitSpot, {radius = sensorRect, isSensor = true})
hitSpot.myName = “hitSpot”
local screenTouch = function( _e )
if _e.phase == “ended” then
dispatcher()
end
end
function dispatcher()
water:play(“water splash”)
water.alpha = 1
hands:play(“handmove splash”)
girl:play(“washFace cleanFace”)
end
function hitSpot:collision(_e)
if _e.other.myName == “hands” then
print(“hands Passed”)
end
end
hitSpot:addEventListener(“collision”, hitSpot)
Runtime:addEventListener (“touch”, screenTouch)
moveRight()[/lua] [import]uid: 51459 topic_id: 14062 reply_id: 52161[/import]