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!

有帮助吗?

解决方案

Just pass the moved var though the function like this:

onTouch({phase="moved"})

Hope this helps

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top