前端之家收集整理的这篇文章主要介绍了
Cocos2dx_视觉差效果层ParallaxNode,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
local topSpeedX = 4.8
local topSpeedY = 0
local middleSpeedX = 1.6
local middleSpeedY = 0
local bgSpeedX = 0.5
local bgSpeedY = 0
local voidNode = cc.ParallaxNode:create()
self:addChild(voidNode)
--近景层
local topSprite = cc.Sprite:create("Heads/Head_6.png")
topSprite:setScale(1.0)
topSprite:setAnchorPoint(cc.p(0,0))
--中景层
local middleSprite = cc.Sprite:create("levelSelectScene/cloud_1.png")
middleSprite:setScale(1.0)
middleSprite:setAnchorPoint(cc.p(0,0))
--远景层
local bgSprite = cc.Sprite:create("game_bg1.png")
bgSprite:setScale(1.0)
bgSprite:setAnchorPoint(cc.p(0,0))
voidNode:addChild(topSprite,3,cc.p(topSpeedX,topSpeedY),cc.p(200,800))
voidNode:addChild(middleSprite,2,cc.p(middleSpeedX,middleSpeedY),cc.p(0,300))
voidNode:addChild(bgSprite,1,cc.p(bgSpeedX,bgSpeedY),0))
local go = cc.MoveBy:create(8,cc.p(-200,0))
local goBack = go:reverse()
local seq = cc.Sequence:create(go,goBack)
voidNode:runAction((cc.RepeatForever:create(seq)))
原文链接:https://www.f2er.com/cocos2dx/341752.html