In this project I have 2 hit areas that connect with to object. Which are wings to a rocket ship. Play must drag each wing to the left and right of the rocket ship. I have a two print statements telling me when each wing has been repaired after that has been completed I would like the program to spit out that the rocket has been repaired. But for some reason it does not tell me that. Can someone please point me in the right direction. Here is my code.
[lua]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR
wordArray = {}
local i = 1
local rand = math.random
local leftX = 100
local leftY = 360
local rightX = 200
local rightY = 360
local rightWingX = 172
local rightWingY = 680
local leftWingX = 132
local leftWingY = 680
–local loqsprite = require(‘loq_sprite’)
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 LeftWing = display.newImageRect(“wingL.png”,67, 67)
LeftWing.x = leftX; LeftWing.y = leftY
local RightWing = display.newImageRect(“wingR.png”,67, 67)
RightWing.x = rightX; RightWing.y = rightY
local hitspotR = display.newImageRect(“hitSpot.png”, 44, 74)
hitspotR.x = 183; hitspotR.y = 690
hitspotR.alpha = 0
local hitspotL = display.newImageRect(“hitSpot.png”, 44, 74)
hitspotL.x = 120; hitspotL.y = 690
hitspotL.alpha = 0
local rocketBody = display.newImageRect(“Body.png”, 46, 149)
rocketBody.x = 150; rocketBody.y = 650
local planet = display.newImageRect(“Planet.png”, 114, 114)
planet.x = 150; planet.y = 150
function hitTestObjects(obj1, obj2)
local left = obj1.contentBounds.xMin <= obj2.contentBounds.xMin and obj1.contentBounds.xMax >= obj2.contentBounds.xMin
local right = obj1.contentBounds.xMin >= obj2.contentBounds.xMin and obj1.contentBounds.xMin <= obj2.contentBounds.xMax
local up = obj1.contentBounds.yMin <= obj2.contentBounds.yMin and obj1.contentBounds.yMax >= obj2.contentBounds.yMin
local down = obj1.contentBounds.yMin >= obj2.contentBounds.yMin and obj1.contentBounds.yMin <= obj2.contentBounds.yMax
return (left or right) and (up or down)
end
local function dragWing(_e)
local t = _e.target
local phase = _e.phase
if _e.phase == “began” then
local parent = t.parent
display.getCurrentStage():setFocus( t )
t.isFocus = true
t.x0 = _e.x - t.x
t.y0 = _e.y - t.y
elseif t.isFocus then
if “moved” == phase then
t.x = _e.x - t.x0
t.y = _e.y - t.y0
elseif “ended” == phase or “cancelled” == phase then
local hitLeft = hitTestObjects(t, hitspotL)
local hitRight = hitTestObjects(t, hitspotR)
if (hitLeft == true) or (hitRight == true) then
if hitLeft then
print(“fixed left”)
LeftWing.x = leftWingX
LeftWing.y = leftWingY
else
print(“fixed right”)
RightWing.x = rightWingX
RightWing.y = rightWingY
end
if hitLeft and hitRight then
print(“both wings in place”)
end
display.getCurrentStage():setFocus( nil )
t.isFocus = false
else
print ( “missed target” )
LeftWing.x = leftX
LeftWing.y = leftY
RightWing.x = rightX
RightWing.y = rightY
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end
end
return true
end
function wingRepair ()
RightWing:addEventListener(“touch”, dragWing)
LeftWing:addEventListener(“touch”, dragWing)
end
wingRepair()[/lua]
thanks! [import]uid: 51459 topic_id: 15924 reply_id: 315924[/import]