欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門(mén)教程網(wǎng)!

C語(yǔ)言

當(dāng)前位置:主頁(yè) > 軟件編程 > C語(yǔ)言 >

cocos2dx實(shí)現(xiàn)刮獎(jiǎng)效果

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語(yǔ)言|點(diǎn)擊: 次

本文實(shí)例為大家分享了cocos2dx刮獎(jiǎng)效果實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下

刮獎(jiǎng)效果其實(shí)挺簡(jiǎn)單的,需要用到RenderTexture來(lái)進(jìn)行渲染,通過(guò)你所要渲染的圖層,把該層的顏色進(jìn)行設(shè)置混合就可以達(dá)到效果,具體看代碼,我用的lua實(shí)現(xiàn)的。

local winsize = cc.Director:sharedDirector():getWinSize(); 
local dataSprite = cc.Sprite:create("Star.png")--要把這個(gè)圖片刮出來(lái) 
dataSprite:setAnchorPoint(cc.p(0.5, 0.5)); 
dataSprite:move(winsize.width / 2.0, winsize.height / 2.0); 
self:addChild(dataSprite) 
 
pEarse = cc.DrawNode:create() 
pEarse:drawDot(cc.p(0, 0), 5, cc.c4f(1, 0, 0, 1)); 
pEarse:retain() 
 
pRTex = cc.RenderTexture:create(winsize.width, winsize.height); 
pRTex:setPosition(cc.p(winsize.width / 2, winsize.height / 2)); 
--this:addChild(pRTex); 
pRTex:retain() 
 
local pBg = cc.Sprite:create("d1.png");--這個(gè)作為當(dāng)“油漆層” 
pBg:setAnchorPoint(cc.p(0.5, 0.5)); 
pBg:move(winsize.width / 2.0, winsize.height / 2.0); 
 
pRTex:begin(); 
dataSprite:visit(); 
pBg:visit(); 
pRTex:endToLua(); 
local layer=cc.Layer:create() 
self:addChild(layer, 1000) 
layer:addChild(pRTex); 
layer:setNodeTouch(handler(self, self.onTouchStart)) 

鼠標(biāo)移動(dòng)代碼:

function shop.erasure(event) 
 -- body 
 print("erasure: ", event.name) 
 --todo 
 print("moved") 
 local touchPoint = event.pos 
 pEarse:setPosition(event.pos.x, event.pos.y); 
 -- 設(shè)置混合模式 
 local blendFunc = { GL_ONE, GL_ZERO }; 
 pEarse:setBlendFunc(blendFunc); 
 -- 將橡皮擦的像素渲染到畫(huà)布上,與原來(lái)的像素進(jìn)行混合 
 pRTex:begin(); 
 pEarse:visit(); 
 pRTex:endToLua(); 
  
end 

C++代碼:

void function()

{

  //test code 
  auto aPanelSprite = Sprite::create("potentiometerTrack.png"); 
  aPanelSprite->setPosition(Vec2(s.width / 2, s.height / 2)); 
  this->addChild(aPanelSprite); 
 
  pEase = DrawNode::create(); 
  pEase->retain(); 
  pEase->drawDot(Point(0, 0), 4.0f, Color4F(255, 0, 0, 255)); 
 
  pRender = RenderTexture::create(s.width, s.height); 
  pRender->retain(); 
  pRender->setPosition(Vec2(s.width / 2, s.height / 2)); 
  this->addChild(pRender); //渲染紋理層需加入該父節(jié)點(diǎn)層 
 
 
 auto pBg = Sprite::create("potentiometerProgress.png"); //這個(gè)作為當(dāng)“油漆層” 
 pBg->setAnchorPoint(Point(0.5, 0.5)); 
 pBg->setPosition(Vec2(s.width / 2, s.height / 2)); 
 
 pRender->begin(); 
 aPanelSprite->visit(); 
 pBg->visit(); 
 pRender->end(); 
 
 auto listener = EventListenerTouchOneByOne::create(); 
 listener->setSwallowTouches(true); 
 
 listener->onTouchBegan = CC_CALLBACK_2(SpriteEaseBezier::onTouchBegan, this); 
 listener->onTouchMoved = CC_CALLBACK_2(SpriteEaseBezier::onTouchMoved, this); 
 
 auto _eventDispatcher = CCDirector::getInstance()->getEventDispatcher(); 
 _eventDispatcher->addEventListenerWithFixedPriority(listener, -10); 
} 
 
bool SpriteEaseBezier::onTouchBegan(Touch *touch, Event *unused_event) 
{ 
 CCLOG("SpriteEaseBezier::onTouchBegan"); 
 return true; 
} 
 
void SpriteEaseBezier::onTouchMoved(Touch *touch, Event *unused_event) 
{ 
 auto touchPoint = touch->getLocation(); 
 pEase->setPosition(touchPoint.x, touchPoint.y); 
 
 BlendFunc blendFunc = { GL_ONE, GL_ZERO }; 
 pEase->setBlendFunc(blendFunc); 
 
 pRender->begin(); 
 pEase->visit(); 
 pRender->end(); 
 CCLOG("SpriteEaseBezier::onTouchMoved"); 
} 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:C++關(guān)于Makefile的詳解含通用模板

欄    目:C語(yǔ)言

下一篇:關(guān)于C++內(nèi)部類(lèi)的介紹與使用示例

本文標(biāo)題:cocos2dx實(shí)現(xiàn)刮獎(jiǎng)效果

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/587.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有