美文网首页
判断点击的是哪个精灵

判断点击的是哪个精灵

作者: Kerwin_lang | 来源:发表于2017-04-01 13:35 被阅读0次
    for i=1,#spriteTable do
        --从spriteTable中获取到精灵sprite
         local sprite = spriteTable[i]
         --获取到touch点
         local p = touch:getLocation()
         --获取到精灵的rect
         local rect = sprite:getBoundingBox()
         --判断touch点是否在精灵的范围之内
         local isTouched = cc.rectContainsPoint(rect,p)
         if (isTouched) then
               --todo
              print(obj.object[i].KindName)
         else
         print("未在有效区域")
         end
    end
    

    相关文章

      网友评论

          本文标题:判断点击的是哪个精灵

          本文链接:https://www.haomeiwen.com/subject/uxdiottx.html