免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

如何在cocos2dx中使用lua實現橡皮擦功能-創新互聯

本篇文章為大家展示了如何在cocos2dx中使用lua實現橡皮擦功能,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

成都創新互聯是專業的元氏網站建設公司,元氏接單;提供做網站、網站建設,網頁設計,網站設計,建網站,PHP網站建設等專業做網站服務;采用PHP框架,可快速的進行元氏網站開發網頁制作和功能擴展;專業做搜索引擎喜愛的網站,專業的做網站團隊,希望更多企業前來合作!

實現原理:隨著觸摸點的移動,通過setBlendFunc函數設置部分區域的顏色混合(將上層圖片透明度為0,底層我們想要的圖片就顯示出來)

--橡皮擦功能測試
local function initInfo()
 local scene = CCScene:create()
 
 local layer = CCLayer:create()
 scene:addChild(layer)
 --擦除后要顯示的圖片
 local tupian = CCSprite:create(ROOT_RES .. "set/tip.png")
 tupian:setPosition(ccp(WinSizeWidth / 2, WinSizeHeight / 2))
 layer:addChild(tupian)
 --涂層
 local tu = CCSprite:create(ROOT_RES..'set/user/BG.png')
 tu:setPosition(ccp(WinSizeWidth/2,WinSizeHeight/2))
 --layer:addChild(tu)
 --將圖層遍歷到texture,再將texture加入當前層
 local ptex = CCRenderTexture:create(1280,720)
 ptex:setPosition(ccp(WinSizeWidth/2,WinSizeHeight/2))
 layer:addChild(ptex)
 ptex:begin()
 tu:visit()
 ptex:endToLua()
 --橡皮擦CCDrawNode
 --point = CCDrawNode:create()
 --point:drawDot(ccp(0,0),10,ccc4f(0,0,0,0))
 local point = CCSprite:create(ROOT_RES..'set/labBtn.png')
 layer:addChild(point)
 --[[local blend = ccBlendFunc()
 blend.src = 0
 blend.dst = 1
 tu:setBlendFunc(blend)--]]
 --local blend = tu:getBlendFunc()
 layer:registerScriptTouchHandler(function (eventType,x,y)
 if eventType == "began" then
  cclog("began")
  return true
 elseif eventType == "moved" then
  cclog("move")
  point:setPosition(x,y)
  local blend = ccBlendFunc()
  blend.src = 1
  blend.dst = 0
  point:setBlendFunc(blend)
  ptex:begin()
  point:visit()
  ptex:endToLua()
 elseif eventType == "ended" then
  cclog("end")
 elseif eventType == "cancelled" then
  
 end
 end,false,-1000,true)
 layer:setTouchEnabled(true)
 return scene
end

function getInfoLayer()
 CCDirector:sharedDirector():replaceScene(initInfo())
end

上述內容就是如何在cocos2dx中使用lua實現橡皮擦功能,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創新互聯行業資訊頻道。

分享題目:如何在cocos2dx中使用lua實現橡皮擦功能-創新互聯
鏈接URL:http://newbst.com/article18/doogdp.html

成都網站建設公司_創新互聯,為您提供營銷型網站建設軟件開發外貿建站自適應網站網站維護網頁設計公司

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

商城網站建設