【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中的使用样例,效果 ...
随机推荐
- 支持AIRPLAY ,DLNA,MIRACAST的HDMI DONGLE
好吧,今天没节操,帮老婆推广一下淘宝的店. 联我影棒 http://item.taobao.com/item.htm?spm=a230r.1.14.132.jqGLCa&id=36476326 ...
- c++ 类内部函数调用虚函数
做项目的过程中,碰到一个问题. 问题可以抽象为下面的问题: 普通人吃饭拿筷子,小孩吃饭拿勺子. class People { public: void eat() { get_util_to_eat( ...
- 【多线程系列】AQS CAS简单介绍
一.什么是CAS CAS(Compare And Swap),即比较并交换.是解决多线程并行情况下使用锁造成性能损耗的一种机制,CAS操作包含三个操作数——内存位置(V).预期原值(A)和新值(B). ...
- 【Eclipse】启动时报错:No Java virtual machine (已解决)
在 Ubuntu 上下了个最新的 Eclipse ,解压后运行报这样的错误: 当然 JDK 的安装及环境变量的配置是没有问题的.使用 java -version 查询本机的JDK版本是可以的. 如果不 ...
- css3整理--rgba
rgba语法: rgba(0, 0, 0,0.5); 第一个参数:R 红色(0-255) 第二个参数:G 绿色(0-255) 第三个参数:B 蓝色(0-255) 第四个参数:透明度(0-1)使用rgb ...
- 关于windows下基于php7.0.2下编写的第一个扩展
网上的教程是比较多的,但是基于php7+windows的教程非常之少,通过几天的摸索及参考很多资料,终于发现如下可以运行. php7要求使用vc2015,同时安装sdk,我使用的是8.1的window ...
- android make-standalone-toolchain.sh 使用说明
#$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-24 --install-dir=./android ...
- php-config
php-config php-config 是一个简单的命令行脚本用于获取所安装的 PHP 配置的信息. 在编译扩展时,如果安装有多个 PHP 版本,可以在配置时用 --with-php-config ...
- dirname的用法:获取文件的父级目录路径
命令:dirname 获取文件的路径(到父级目录)用法:dirname file_name [root@bogon opt]# a=$(dirname /mnt/a/b/c/d/a.sh) [root ...
- C程序设计语言习题(1-12)
统计行数.单词数,字符数的程序: #include<stdio.h> #define IN 1 /*在单词内*/ #define OUT 0 /*在单词外*/ int main() { i ...