当前位置 : 主页 > 手机开发 > 其它 >

cocos2dx的一些效果

来源:互联网 收集:自由互联 发布时间:2021-06-13
@ 绽开效果 1. animalNode:setScale(0.1) 2. animalNode:setOpacity(0) 3. local action1 = cc.Spawn:create(cc.ScaleTo:create(0.15, 2.0),cc.FadeTo:create(0.15,255)) 4. local action = cc.Sequence:create(action1,cc.DelayTime:create(1.0)) @ 缓冲

@绽开效果

	1. animalNode:setScale(0.1)  
	2. animalNode:setOpacity(0)  
	3. local action1 = cc.Spawn:create(cc.ScaleTo:create(0.15, 2.0),cc.FadeTo:create(0.15,255))  
	4. local action  = cc.Sequence:create(action1,cc.DelayTime:create(1.0))  


缓冲效果:
弹跳缓冲(Bounce):EaseBounceIn、EaseBounceOut、EaseBounceInOut; 弹性缓冲(跟上面啥区别呢?看有没有越界…):EaseElasticIn、EaseElasticOut、EaseElasticInOut; 回震缓冲:EaseBackIn、EaseBackOut、EaseBackInOut;

@ 卷轴打开效果:

--[[
	--ClippingNode test 
    local clipnode = cc.ClippingNode:create()   
    clipnode:setPosition(568,320) 
    self:addChild(clipnode) 

    --属性设置    
    clipnode:setInverted(false)       --倒置显示,未被裁剪下来的剩余部分    
    clipnode:setAlphaThreshold(0.5)  --设置alpha透明度闸值       

    --创建模板    
    local Stencil = cc.Node:create()   
    clipnode:setStencil(Stencil) --设置模板节点    
     
    --添加一个模板遮罩 ball    
    local spp = cc.Sprite:create("common/anim1.png")
    Stencil:addChild(spp)

    --添加另一个底板内容 blocks    
    local content = cc.Sprite:create("common/b1.png")    
    clipnode:addChild(content)
 --]]
    local juanzhouWidget = self:getWidget("Image_juanzhou") 
    local zhouleftWidget = self:getWidget("Image_zhouleft")
	local zhourightWidget = self:getWidget("Image_zhouright")
    juanzhouWidget:setVisible(false)
    zhouleftWidget:setVisible(false)
    zhourightWidget:setVisible(false)

	local clipnode = cc.ClippingNode:create()   
    clipnode:setPosition(568,320) 
    self:addChild(clipnode) 
    --属性设置    
    clipnode:setInverted(false)       --倒置显示,未被裁剪下来的剩余部分    
    clipnode:setAlphaThreshold(0.5)  --设置alpha透明度闸值     

	--创建模板     
    local Stencil = cc.Sprite:create("common/mid_background.png")
    clipnode:setStencil(Stencil) --设置模板节点  

    --添加另一个底板内容 blocks    
    local content = cc.Sprite:create("common/shufa.png")    
    clipnode:addChild(content)

    local zhouleft = cc.Sprite:create("common/left.png")    
    zhouleft:setPosition(zhouleftWidget:getPosition())
    self:addChild(zhouleft)

    local zhouright = cc.Sprite:create("common/right.png")    
    zhouright:setPosition(zhourightWidget:getPosition())
    self:addChild(zhouright)

    local function Callback()
    	scheduler:unscheduleScriptEntry(self.schedu)
    end

    local actTime = 2 --动画时间
    local callfunc = cc.CallFunc:create(Callback)

	local moveleft = cc.MoveBy:create(actTime, cc.p(-290,0))
	local moveright = cc.MoveBy:create(actTime, cc.p(290,0))
	local seq = cc.Sequence:create(moveright,callfunc)
	zhouleft:runAction(moveleft)
	zhouright:runAction(seq)

	local scale = 0
	local function funCallback()
		Stencil:setScaleX(scale)
		scale = scale + 0.26
    end
   self.schedu = scheduler:scheduleScriptFunc(funCallback, 0.002, false)

@切换效果

--图片裁切,像捕鱼一样的效果。
    local clipnode1 = cc.ClippingNode:create()   
    clipnode1:setPosition(0,320) 
    self:addChild(clipnode1) 
    --属性设置    
    clipnode1:setInverted(true)       --倒置显示,未被裁剪下来的剩余部分    
    clipnode1:setAlphaThreshold(0.5)  --设置alpha透明度闸值     

	--创建模板     
    local Stencil1 = cc.Sprite:create("common/bar2.png")
    Stencil1:setAnchorPoint(0,0.5)
    clipnode1:setStencil(Stencil1) --设置模板节点  

    --添加另一个底板内容,背景 blocks    
    local sp1 = cc.Sprite:create("bk/bg.jpg")    
    sp1:setPosition(winSize.width/2,0)
    clipnode1:addChild(sp1)
    ------------------------------
    local clipnode2 = cc.ClippingNode:create()   
    clipnode2:setPosition(0,320) 
    self:addChild(clipnode2) 
    --属性设置    
    clipnode2:setInverted(false)       --倒置显示,未被裁剪下来的剩余部分    
    clipnode2:setAlphaThreshold(0.5)  --设置alpha透明度闸值     

	--创建模板     
    clipnode2:setStencil(Stencil1) --设置模板节点  

    --添加另一个底板内容,背景 blocks    
    local sp2 = cc.Sprite:create("bk/main.jpg")    
    sp2:setPosition(winSize.width/2,0)
    clipnode2:addChild(sp2)

    local scale = 0
	local function funCallback()
		Stencil1:setScaleX(scale)
		if scale >= 12 then
			scheduler:unscheduleScriptEntry(self.schedu)
			return
		end
		scale = scale + 0.1
    end
   self.schedu = scheduler:scheduleScriptFunc(funCallback, 0.02, false)

@永久旋转:

node:runAction(cc.RepeatForever:create(cc.RotateBy:create(1,90)))

网友评论