Question

I am quite new to Corona SDK and could use some help. I am creating a connect the dots game and am running into a problem with re-setting focus.

Each dot has an onTouch event:

function onTouch(self, event)
  if event.phase == "began" then
    display.getCurrentStage():setFocus( self )
    table.insert( selectedDots, self )
    self.isSelected = true
  elseif event.phase == "moved" then
    display.getCurrentStage():setFocus( self )
    if self.Selected == false then
      table.insert( selectedDots, self )
      self.Selected = true
    end
  elseif event.phase == "ended" or event.phase == "cancelled"  then
    --remove dots
  end
end

Basically, I want players to press a dot and hold and any other dots they touch while holding are "selected." I had everything working, until I realized that unless players ended their touch on a dot, the ended phase would not trigger.

Any help/advice would be greatly appreciated. I'm stuck!

Was it helpful?

Solution

Just pass the moved var though the function like this:

onTouch({phase="moved"})

Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top