教程:【原生】CocosCreator 原生 热更新(demo源码、动态热更、强更新)
工程文件:
cocos热更新工程.zip
cocos代码工程
分类: cocos/layabox
layabox实现自定义动画
来源:tanglijun
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="./LayaAirJS_1.7.19.1_beta/js/libs/laya.core.js"></script>
<script src="./LayaAirJS_1.7.19.1_beta/js/libs/laya.webgl.js"></script>
</head>
<body>
<script>
(function() {
var Sprite = Laya.Sprite;
var Stage = Laya.Stage;
var Event = Laya.Event;
var Browser = Laya.Browser;
var WebGL = Laya.WebGL;
var ape;
var scaleDelta = 0;
;(function () {
// 不支持 WebGL 时自动切换至 Canvas
Laya.init(Browser.clientWidth, Browser.clientHeight, WebGL)
Laya.stage.alignV = Stage.ALIGN_MIDDLE
Laya.stage.alignH = Stage.ALIGN_CENTER
Laya.stage.scaleMode = 'showall'
Laya.stage.bgColor = '#232628'
createApe()
}());
function createApe() {
ape = new Sprite();
// 加载图片
ape.loadImage('./res/apes/monkey2.png');
// 添加图形到舞台中
Laya.stage.addChild(ape);
// 设置中心点 (monkey2.png 110 * 145)
ape.pivot(55, 72);
// 设置图形的 x 坐标
ape.x = Laya.stage.width / 2;
// 设置图形的 y 坐标
ape.y = Laya.stage.height / 2;
// 设置没 1 帧的动画
Laya.timer.frameLoop(1, this, animate);
}
function animate(e) {
// 旋转角度增加 2 度
ape.rotation += 2;
// 设置心跳缩放比例
scaleDelta += 0.02;
var scaleValue = Math.sin(scaleDelta);
ape.scale(scaleValue, scaleValue);
}
})()
</script>
</body>
</html>
cocos KeyError: u’custom’
报错
编译模式:release
Traceback (most recent call last):
File "D:\CocosSoftware\Cocos2d-x\cocos2d-x-3.13\tools\cocos2d-console\bin\/cocos.py", line 998, in <module>
run_plugin(command, argv, plugins)
File "D:\CocosSoftware\Cocos2d-x\cocos2d-x-3.13\tools\cocos2d-console\bin\/cocos.py", line 916, in run_plugin
plugin.run(argv, dependencies_objects)
File "D:\CocosSoftware\Cocos2d-x\cocos2d-x-3.13\tools\cocos2d-console\plugins\plugin_compile\project_compile.py", line 1550, in run
self.build_web()
File "D:\CocosSoftware\Cocos2d-x\cocos2d-x-3.13\tools\cocos2d-console\plugins\plugin_compile\project_compile.py", line 1233, in build_web
build_web.gen_buildxml(project_dir, project_json, publish_dir, buildOpt)
File "D:\CocosSoftware\Cocos2d-x\cocos2d-x-3.13\tools\cocos2d-console\plugins\plugin_compile\build_web\__init__.py", line 73, in gen_buildxml
arr = _getJsListOfModule(ccModuleMap, item)
File "D:\CocosSoftware\Cocos2d-x\cocos2d-x-3.13\tools\cocos2d-console\plugins\plugin_compile\build_web\__init__.py", line 118, in _getJsListOfModule
tempList = moduleMap[moduleName]
KeyError: u'custom'
解决方法
//文件frameworks\cocos2d-html5\moduleConfig.json
//其他代码
"external" : ["box2d", "chipmunk", "socketio", "pluginx", "gaf"],
"custom" : ["core", "audio", "gui", "editbox", "cocostudio", "shape-nodes", "render-texture"]