【Cocos2dx 3.x Lua】CCParallaxNode使用
|
local mapRes={
near=string.format("%s.%s",Resource_1.map.near.loc,Resource_1.map.near.rtype),
middle=string.format("%s.%s",Resource_1.map.middle.loc,Resource_1.map.near.rtype),
far=string.format("%s.%s",Resource_1.map.far.loc,Resource_1.map.near.rtype)
}
local MapParallaxNode=class("MapParallaxNode",function()
return cc.ParallaxNode:create()
end)
MapParallaxNode.ctor=function(self)
local s=cc.Director:getInstance():getVisibleSize()
self._nearBg=nil
self._middleBg=nil
self._farBg=nil
self._layerNode=nil
self:initFarBg()
self:initMiddleBg()
self:initNearBg()
self:setPosition(,)
self:setAnchorPoint(cc.p(,))
self:addChild(self._farBg, -, cc.p(0.03,), cc.p(,s.height+))
self:addChild(self._middleBg, , cc.p(0.18,), cc.p(,s.height*/+) )
self:addChild(self._nearBg, , cc.p(0.65,), cc.p(,s.height*/+))
end
--初始化地图近景
MapParallaxNode.initNearBg=function(self)
local cache=cc.Director:getInstance():getTextureCache()
local texture=cache:getTextureForKey(mapRes.near)
local sprite=cc.Sprite:createWithTexture(texture)
sprite:setPositionX()
sprite:setScale(0.43)
sprite:setAnchorPoint(cc.p(,))
self._nearBg=sprite
end
--初始化地图中景
MapParallaxNode.initMiddleBg=function(self)
local cache=cc.Director:getInstance():getTextureCache()
local texture=cache:getTextureForKey(mapRes.middle)
local sprite=cc.Sprite:createWithTexture(texture)
sprite:setScale(0.7)
sprite:setAnchorPoint(cc.p(,))
self._middleBg=sprite
end
--初始化地图远景
MapParallaxNode.initFarBg=function(self)
local cache=cc.Director:getInstance():getTextureCache()
local texture=cache:getTextureForKey(mapRes.far)
local sprite=cc.Sprite:createWithTexture(texture)
sprite:setScale(0.4)
sprite:setAnchorPoint(cc.p(,))
self._farBg=sprite
end
MapParallaxNode.create=function(self)
return MapParallaxNode.new()
end
return MapParallaxNode
self:addChild(self._farBg, -1, cc.p(0.03,0), cc.p(0,s.height+20)) self:addChild(self._middleBg, 1, cc.p(0.18,0), cc.p(5,s.height*2/3+90) ) self:addChild(self._nearBg, 2, cc.p(0.65,0), cc.p(0,s.height*2/3+40))
parallaxRatio是设置不同层的x,y移动速度
【Cocos2dx 3.x Lua】CCParallaxNode使用的更多相关文章
- Cocos2d-x 3.2 Lua演示样例 ClickAndMoveTest(点击移动測试)
Cocos2d-x 3.2 Lua演示样例 ClickAndMoveTest(点击移动測试) 本篇博客介绍Cocos2d-x 3.2Lua演示样例中点击移动的样例,在这个样例你能够得到怎样创建单点触 ...
- Cocos2d-x 脚本语言Lua中的面向对象
Cocos2d-x 脚本语言Lua中的面向对象 面向对象不是针对某一门语言,而是一种思想.在面向过程的语言也能够使用面向对象的思想来进行编程. 在Lua中,并没有面向对象的概念存在,没有类的定义和子类 ...
- Cocos2d-x 3.2 Lua演示样例 XMLHttpRequestTest(Http网络请求)
Cocos2d-x 3.2 Lua演示样例 XMLHttpRequestTest(Http网络请求) 本篇博客介绍Cocos2d-x 3.2Lua演示样例中的XMLHttpRequestTes ...
- Cocos2d-x 3.2 Lua演示样本CocosDenshionTest(音频测试)
Cocos2d-x 3.2 Lua演示样本CocosDenshionTest(音频测试) 本篇博客介绍Cocos2d-x 3.2中Lua演示样例的音频測试.Cocos2d-x使用SimpleAudi ...
- Cocos2d-x 脚本语言Lua使用
Cocos2d-x 脚本语言Lua使用 前面几篇博客已经把Lua的相关基础知识介绍了.本篇博客就来介绍一下,怎样在Cocos2d-x项目中使用Lua这门脚本语言进行开发.因为笔者使用的时Mac系统.所 ...
- 笔记:利用Cocos2dx 3.3 lua 做一个动作类游戏(一)
在这之前,声明一下: 做不完我是小狗. 没办法,没毅力和恒心,之前的那个Quick Cocos2dx做的横版过关游戏的demo已经转成了3.3的版本了,其实也算是个半成品,战斗,UI啥的都有了,呵呵. ...
- 【Cocos2dx 3.3 Lua】滚动字幕
参考资料: http://blog.csdn.net/jackystudio/article/details/12991977 1.原理 通过调用update来更新位置达到 ...
- 【Cocos2dx 3.3 Lua】定时器事件
Cocos2dx 3.x Lua 中使用定时器有两种方式: (1)self:scheduleUpdateWithPriorityLua(update, priority) > 参数一:刷新函数 ...
- 【Cocos2dx 3.x Lua】TileMap使用
1.编辑TileMap地图资源 2.Cocos2dx 3.x Lua中使用TileMap Link: http://codepad.org/P0nFP1Dx local TileMap=clas ...
- Cocos2d-x 3.2 Lua演示样例 AssetsManagerTest(资源管理器)
Cocos2d-x 3.2 Lua演示样例 AssetsManagerTest(资源管理器) 本篇博客介绍Cocos2d-x 为我们提供的一个类--AssetsManager在Lua中的使用样例,效果 ...
随机推荐
- #define #undef
#include <stdio.h> int main( void ) { #define MAX 200 printf("MAX= %d\n",MAX); #unde ...
- Delphi应用程序的调试(四)The Debug Inspector
调试检查器(The Debug Inspector) Debug Inspector使用户能查看诸如类和记录的数据对象,也可以用它来查看整数.字符数组等简单数据类型,但这类简单数据类型最好是用Watc ...
- 浅谈CSS盒子模型
[摘要]盒子模型是CSS中的一个重要概念,虽然CSS中没有盒子这个单独的属性对象,但它却是CSS中无处不在的一个重要组成部分.掌握盒子模型的原理和使用方法可以极大地丰富HTML元素的表现效果,同时对于 ...
- 原生js(三)
客户端js的时间线: 1.web浏览器创建Document对象,开始解析html和文本.生成Element对象和Text节点添加到文档中.这个阶段的document.readystate==" ...
- python编程中的if __name__ == 'main': 的作用和原理
在大多数编排得好一点的脚本或者程序里面都有这段if __name__ == 'main': ,虽然一直知道他的作用,但是一直比较模糊,收集资料详细理解之后与打架分享. 1.这段代码的功能 一个pyth ...
- How to Use Postman to Manage and Execute Your APIs
How to Use Postman to Manage and Execute Your APIs Postman is convenient for executing APIs because ...
- Egret IDE中搜索,过滤文件,只搜索.ts
刚开始忘了这个搜索条件在哪里打开了,后来找着了,记录一下 = =!
- 预编译 ASP.NET 网站以进行部署
预编译 ASP.NET 网站以进行部署和更新 打开一个命令窗口并定位到包含 .NET Framework 的文件夹. .NET Framework 将安装在以下位置. %windir%\Microso ...
- css如何设置div中的内容垂直居中?
<style>.out { position: relative;//相对div的定位 top: 30%;//相对div的border-top的距离,根据元素的高度,50%则为垂直居中:} ...
- iOS - 引用计数探讨
<Objective-C 高级编程> 这本书有三个章节,我针对每一章节进行总结并加上适当的扩展分享给大家.可以从下面这张图来看一下这三篇的整体结构: 注意,这个结构并不和书中的结构一致,而 ...