cocos2dx_lua 开发笔记
备注说明:
1、游戏引擎:quick 3.6.5/3.6.6 (cocos2dx_lua 社区版)
2、以下笔记纯属我个人在实际开发中积累的,非网上直接复制粘贴,
其中包括一些隐蔽 bug 解决方案,希望对相关游戏开发人员有所帮
助,不喜勿喷,谢谢。
一、基本控件
1、图层创建(带颜色背景)
local mNode = cc.LayerColor:create(cc.c4b(0,0,0,255))
mNode:setContentSize(500,500)
mNode:ignoreAnchorPointForPosition(false)--消除自带锚点
mNode:setAnchorPoint(0.5,0.5)--设置新锚点
mNode:setPosition(cc.p(960,540))
self:addChild(mNode)
2、webview 的使用
local webview = ccexp.WebView:create()
self:addChild(webview)
webview:setVisible(true)
webview:setScalesPageToFit(true)
webview:loadURL("http://www.baidu.com")
webview:setContentSize(cc.size(500,300)) -- 一定要设置大小才能显示
webview:reload()
webview:setPosition(display.cx,display.cy)
这个是 3.6.5 版本提供的 API,必须要在真机上才能测试;
3、动态布局进度条
// m_webLayout = new FrameLayout(this);
//// addContentView(m_webLayout, new
FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
FrameLayout.LayoutParams.FILL_PARENT));
// addContentView(m_webLayout, new FrameLayout.LayoutParams(800, 20));
//// TextView tv = new TextView(this);
//// tv.setText("Hello World");