Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function placeNote() -- Select a Square !!!
- -- This removes previous sparkler effects on where you touched.
- for i= 1, # mapNotes do
- sparkler[i]:removeEventListener( "touch", readNote )
- end
- --atrace (mapNotes)
- mapIsDrawn = false -- probably ignore
- mapNoteNumber = mapNoteNumber + 1 -- ingore
- -- This where they go when
- -- someone touches the invisible overlay group.maps.elements.mapTouchArea
- touched = function( event )
- local cancelMapNote = false
- local t = event.target
- local phase = event.phase
- local tempX = eventX
- local tempY = eventY
- if ("began" == phase ) then
- t.isFocus = true
- t.x0 = event.x
- t.y0 = event.y
- local effect = display.newRect(1,1,16,16)
- effect:setFillColor(tonumber("27", 16), tonumber("207", 16), tonumber("147", 16))
- -- BELOW:
- -- find the middle X,Y for the place on
- -- the screen to draw the nifty effect
- tempX = (((math.floor ( (t.x0-33) / 16 ) ) ) ) +1
- tempY = ((math.floor ( (t.y0-97) / 16 ) ) ) + 1
- --print ("tempx,y" .. tempX, tempY) -- always print stuff
- -- below, converts XY based on
- -- the touched screen's X(thetempX),Y(the tempY) of where they touched
- -- The reason I do this is because I use XY to find a place in a table map.
- -- ie. if you are in the very top left hand corner XY=1. if your map is 20x20 and
- -- you want to go down one, then XY=XY + 20. Up the mapTable is XY=XY-20.
- mapNotes[mapNoteNumber].MessageXY = (( (tempY-1) * currentMap.mapWidth ) + tempX )
- -- io.write ("->" .. (( (tempY-1) * currentMap.mapWidth ) + tempX ) )
- -- io.write ("\n\n**************************")
- -- io.write ("\nEventX,Y:" .. " X" .. event.x .. " / Y" .. event.y) -- 33 , 97
- -- io.write ("\nMath Check: X " .. math.floor ( (event.x-33) / 16 )+1 )
- -- io.write ("\nMath Check: Y " .. math.floor ( (event.y-97) / 16 )+1 )
- --print ("mapNote#:" .. mapNoteNumber)
- --print ("tempX" .. tempX )
- --print ("tempY" .. tempY )
- if mapNotes[1] ~= nil then
- local compare
- for i= 1, #mapNotes do
- --print (" THIS MANY MAP NOTES! ")
- if mapNotes[i].MessageXY == (( (tempY-1) * currentMap.mapWidth ) + tempX ) then
- --print (" Found a match")
- cancelMapNote = true
- mapNoteNumber = i
- end
- end
- end
- effect.x = ( ( math.floor ( (event.x-33) / 16 ) ) *16 ) + 32 + 8
- effect.y = ( ( math.floor ( (event.y-97) / 16 ) ) *16 ) + 96 + 8
- group.maps.groups['ScrollMap']:insert( effect )
- effect.alpha = .5
- local function effectAnimate(e)
- local finishedEffect = function()
- effect:removeSelf()
- if cancelMapNote then
- else
- table.insert ( mapNotes, { Message = "new Map Note", MessageXY = 0 } )
- mapNotes[mapNoteNumber].MessageXY = (( (tempY-1) * currentMap.mapWidth ) + tempX )
- end
- typeNote(mapNotes[mapNoteNumber].Message)
- end
- local fadeDown = function()
- transition.to ( e, { time = 200, alpha=1 , xScale= 1, yScale=1, onComplete = finishedEffect} )
- end
- effect.alpha = 0
- transition.to ( e, { time = 200, alpha=.6 , xScale= 8, yScale=8, onComplete = fadeDown } )
- end
- effectAnimate (effect)
- end
- local function EffectOver()
- end
- if ("ended" ==phase) then
- end
- t.x0 = nil
- t.y0 = nil
- end
- group.maps.elements.btnSpellbook.isVisible = false
- group.maps.elements.btnSpellbook:setEnabled(false, 'up')
- group.maps.elements.btnLeft.onTap = returnToGameFromList
- -- group.maps.elements.Text_Header.text = ( rosetta:getString("Quests") )
- group.maps.elements.Text_Header.text = rosetta:getString( "PLACE A NOTE" )
- group.maps.elements.Text_Sub1.text = ( " " )
- group.maps.elements.mapTouchArea.isVisible = true
- group.maps.elements.mapTouchArea.alpha = .3
- group.maps.elements.mapTouchArea:addEventListener("touch" , touched)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement