├── src ├── version.lua ├── gk │ ├── .gitignore │ ├── res │ │ ├── 3d │ │ │ ├── orc.c3b │ │ │ └── monguger.tga │ │ ├── texture │ │ │ ├── info.png │ │ │ ├── ipx.png │ │ │ ├── arrow.png │ │ │ ├── btn_bg.png │ │ │ ├── close.png │ │ │ ├── frame.png │ │ │ ├── edit_box_bg.png │ │ │ ├── icon_cocos.png │ │ │ ├── default_debug.png │ │ │ ├── icon_android.png │ │ │ ├── check_box_normal.png │ │ │ ├── default_release.png │ │ │ ├── select_box_popup.png │ │ │ ├── check_box_selected.png │ │ │ ├── check_box_normal_gray.png │ │ │ └── check_box_selected_gray.png │ │ ├── font │ │ │ ├── Consolas.png │ │ │ ├── Consolas.ttf │ │ │ └── Consolas.GlyphProject │ │ ├── data │ │ │ ├── tmw_desert_spacing.png │ │ │ ├── default.tsx │ │ │ └── default.tmx │ │ ├── shader │ │ │ ├── Highlight.fsh │ │ │ ├── Mvp.vsh │ │ │ ├── NoMvp.vsh │ │ │ └── Freeze.fsh │ │ └── particle │ │ │ └── Galaxy.plist │ ├── test │ │ ├── gen │ │ │ ├── layout │ │ │ │ ├── gk_test_fsm_fsmtest.lua │ │ │ │ ├── gk_test_dialogtest.lua │ │ │ │ ├── gk_test_api_apitest.lua │ │ │ │ ├── gk_test_api_shadertest.lua │ │ │ │ ├── gk_test_widget_textbutton.lua │ │ │ │ ├── gk_test_widget_popupbg.lua │ │ │ │ ├── gk_test_tableviewtest.lua │ │ │ │ ├── gk_test_c3dlayertest.lua │ │ │ │ ├── gk_test_dialog_dialog1.lua │ │ │ │ ├── gk_test_particlesystemtest.lua │ │ │ │ ├── gk_test_shadertest.lua │ │ │ │ ├── gk_test_progresstimertest.lua │ │ │ │ ├── gk_test_drawnodetest.lua │ │ │ │ ├── gk_test_cell_tablecell1.lua │ │ │ │ └── gk_test_solarsystem.lua │ │ │ ├── value │ │ │ │ ├── strings_cn.lua │ │ │ │ └── strings.lua │ │ │ └── config.lua │ │ ├── res │ │ │ ├── font │ │ │ │ ├── Klee.png │ │ │ │ ├── Cambria.png │ │ │ │ ├── Verdana.ttf │ │ │ │ └── chars.png │ │ │ └── texture │ │ │ │ ├── aq1.png │ │ │ │ ├── rect.png │ │ │ │ ├── Hello.png │ │ │ │ ├── avatar.png │ │ │ │ ├── normal.png │ │ │ │ ├── pop_b.png │ │ │ │ ├── pop_l.png │ │ │ │ ├── pop_r.png │ │ │ │ ├── pop_t.png │ │ │ │ ├── disabled.png │ │ │ │ ├── particle.png │ │ │ │ ├── selected.png │ │ │ │ ├── stencil.png │ │ │ │ └── splash │ │ │ │ └── arc.jpg │ │ ├── model │ │ │ └── model.lua │ │ ├── ShaderTest.lua │ │ ├── fsm │ │ │ ├── GameFSM.lua │ │ │ └── FSMTest.lua │ │ ├── DrawNodeTest.lua │ │ ├── NodeTest.lua │ │ ├── dialog │ │ │ └── Dialog1.lua │ │ ├── widget │ │ │ ├── PopupBg.lua │ │ │ └── TextButton.lua │ │ ├── LabelTest.lua │ │ ├── DialogTest.lua │ │ ├── ParticleSystemTest.lua │ │ ├── ProgressTimerTest.lua │ │ ├── ButtonTest.lua │ │ ├── ClippingNodeTest.lua │ │ ├── SolarSystem.lua │ │ ├── Path.lua │ │ ├── api │ │ │ └── APITest.lua │ │ ├── TableViewTest.lua │ │ ├── C3DLayerTest.lua │ │ └── cell │ │ │ └── TableCell1.lua │ ├── fsm │ │ ├── init.lua │ │ └── FSMEditor.lua │ ├── action │ │ ├── init.lua │ │ └── BreathAction.lua │ ├── controller │ │ ├── init.lua │ │ ├── shader.lua │ │ └── SceneManager.lua │ ├── core │ │ ├── log.lua │ │ ├── List.lua │ │ ├── audio.lua │ │ ├── init.lua │ │ └── event.lua │ ├── tools │ │ ├── init.lua │ │ ├── profile.lua │ │ ├── ErrorReporter.lua │ │ └── scheduler.lua │ ├── node │ │ ├── TableViewCell.lua │ │ ├── Widget.lua │ │ ├── CheckBox.lua │ │ ├── DrawPoint.lua │ │ ├── DrawLine.lua │ │ ├── DrawCardinalSpline.lua │ │ ├── DrawNodeCircle.lua │ │ ├── DrawPolygon.lua │ │ ├── DrawNode.lua │ │ ├── QuadBezierNode.lua │ │ ├── CubicBezierNode.lua │ │ ├── ToggleButton.lua │ │ ├── Scene.lua │ │ ├── ZoomButton.lua │ │ ├── SpriteButton.lua │ │ └── Dialog.lua │ ├── gen │ │ ├── config.lua │ │ └── layout │ │ │ ├── gk_layout_fsmnode.lua │ │ │ ├── gk_layout_fsmtransnode.lua │ │ │ └── gk_layout_errorreportdialog.lua │ ├── layout │ │ ├── ErrorReportDialog.lua │ │ ├── FSMNode.lua │ │ └── FSMTransNode.lua │ ├── editor │ │ ├── init.lua │ │ ├── config3d.lua │ │ └── theme.lua │ ├── init.lua │ ├── instanceRun.lua │ ├── script │ │ └── push.py │ └── hotUpdate.lua ├── demoapp │ ├── res │ │ └── texture │ │ │ ├── main │ │ │ ├── dot.png │ │ │ ├── avatar.png │ │ │ └── default_hd_avatar.png │ │ │ └── splash │ │ │ └── arc.jpg │ ├── ChatCell.lua │ ├── gen │ │ ├── value │ │ │ ├── strings_cn.lua │ │ │ └── strings.lua │ │ ├── layout │ │ │ ├── demoapp_splashlayer.lua │ │ │ ├── demoapp_chatcell.lua │ │ │ └── demoapp_mainlayer.lua │ │ └── config.lua │ ├── SplashLayer.lua │ └── MainLayer.lua ├── config.lua └── main.lua ├── res └── 3d │ ├── orc.c3b │ ├── body.png │ ├── boss.c3b │ ├── boss.png │ ├── girl.c3b │ ├── monguger.tga │ ├── skybox │ ├── back.jpg │ ├── left.jpg │ ├── top.jpg │ ├── bottom.jpg │ ├── front.jpg │ └── right.jpg │ ├── cube_map.frag │ └── cube_map.vert ├── snapshots ├── ss1.png ├── ss2.png ├── ss3.png └── ss4.png ├── .gitignore ├── .cocos-project.json ├── config.json ├── README.md └── LICENSE.TXT /src/version.lua: -------------------------------------------------------------------------------- 1 | return "1.0.0" -------------------------------------------------------------------------------- /src/gk/.gitignore: -------------------------------------------------------------------------------- 1 | core/runtimeversion.lua -------------------------------------------------------------------------------- /res/3d/orc.c3b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/orc.c3b -------------------------------------------------------------------------------- /res/3d/body.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/body.png -------------------------------------------------------------------------------- /res/3d/boss.c3b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/boss.c3b -------------------------------------------------------------------------------- /res/3d/boss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/boss.png -------------------------------------------------------------------------------- /res/3d/girl.c3b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/girl.c3b -------------------------------------------------------------------------------- /snapshots/ss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/snapshots/ss1.png -------------------------------------------------------------------------------- /snapshots/ss2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/snapshots/ss2.png -------------------------------------------------------------------------------- /snapshots/ss3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/snapshots/ss3.png -------------------------------------------------------------------------------- /snapshots/ss4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/snapshots/ss4.png -------------------------------------------------------------------------------- /res/3d/monguger.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/monguger.tga -------------------------------------------------------------------------------- /res/3d/skybox/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/skybox/back.jpg -------------------------------------------------------------------------------- /res/3d/skybox/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/skybox/left.jpg -------------------------------------------------------------------------------- /res/3d/skybox/top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/skybox/top.jpg -------------------------------------------------------------------------------- /src/gk/res/3d/orc.c3b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/3d/orc.c3b -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .settings 2 | .swap 3 | .idea 4 | .project 5 | *.iml 6 | frameworks/ 7 | runtime/ 8 | src/cocos/ 9 | -------------------------------------------------------------------------------- /res/3d/skybox/bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/skybox/bottom.jpg -------------------------------------------------------------------------------- /res/3d/skybox/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/skybox/front.jpg -------------------------------------------------------------------------------- /res/3d/skybox/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/res/3d/skybox/right.jpg -------------------------------------------------------------------------------- /src/gk/res/3d/monguger.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/3d/monguger.tga -------------------------------------------------------------------------------- /src/gk/res/texture/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/info.png -------------------------------------------------------------------------------- /src/gk/res/texture/ipx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/ipx.png -------------------------------------------------------------------------------- /src/gk/res/font/Consolas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/font/Consolas.png -------------------------------------------------------------------------------- /src/gk/res/font/Consolas.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/font/Consolas.ttf -------------------------------------------------------------------------------- /src/gk/res/texture/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/arrow.png -------------------------------------------------------------------------------- /src/gk/res/texture/btn_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/btn_bg.png -------------------------------------------------------------------------------- /src/gk/res/texture/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/close.png -------------------------------------------------------------------------------- /src/gk/res/texture/frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/frame.png -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_fsm_fsmtest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _id = "fSMTest1", 3 | height = "$fill", 4 | width = "$fill"} -------------------------------------------------------------------------------- /src/gk/test/res/font/Klee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/font/Klee.png -------------------------------------------------------------------------------- /src/gk/test/res/font/Cambria.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/font/Cambria.png -------------------------------------------------------------------------------- /src/gk/test/res/font/Verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/font/Verdana.ttf -------------------------------------------------------------------------------- /src/gk/test/res/font/chars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/font/chars.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/aq1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/aq1.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/rect.png -------------------------------------------------------------------------------- /.cocos-project.json: -------------------------------------------------------------------------------- 1 | { 2 | "engine_version": "cocos2d-x-3.15", 3 | "has_native": true, 4 | "project_type": "lua" 5 | } -------------------------------------------------------------------------------- /src/gk/res/texture/edit_box_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/edit_box_bg.png -------------------------------------------------------------------------------- /src/gk/res/texture/icon_cocos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/icon_cocos.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/Hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/Hello.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/avatar.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/normal.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/pop_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/pop_b.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/pop_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/pop_l.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/pop_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/pop_r.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/pop_t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/pop_t.png -------------------------------------------------------------------------------- /src/demoapp/res/texture/main/dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/demoapp/res/texture/main/dot.png -------------------------------------------------------------------------------- /src/gk/res/font/Consolas.GlyphProject: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/font/Consolas.GlyphProject -------------------------------------------------------------------------------- /src/gk/res/texture/default_debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/default_debug.png -------------------------------------------------------------------------------- /src/gk/res/texture/icon_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/icon_android.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/disabled.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/particle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/particle.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/selected.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/stencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/stencil.png -------------------------------------------------------------------------------- /src/demoapp/res/texture/main/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/demoapp/res/texture/main/avatar.png -------------------------------------------------------------------------------- /src/demoapp/res/texture/splash/arc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/demoapp/res/texture/splash/arc.jpg -------------------------------------------------------------------------------- /src/gk/res/data/tmw_desert_spacing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/data/tmw_desert_spacing.png -------------------------------------------------------------------------------- /src/gk/res/texture/check_box_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/check_box_normal.png -------------------------------------------------------------------------------- /src/gk/res/texture/default_release.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/default_release.png -------------------------------------------------------------------------------- /src/gk/res/texture/select_box_popup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/select_box_popup.png -------------------------------------------------------------------------------- /src/gk/test/res/texture/splash/arc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/test/res/texture/splash/arc.jpg -------------------------------------------------------------------------------- /src/gk/res/texture/check_box_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/check_box_selected.png -------------------------------------------------------------------------------- /src/gk/res/texture/check_box_normal_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/check_box_normal_gray.png -------------------------------------------------------------------------------- /src/gk/res/texture/check_box_selected_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/gk/res/texture/check_box_selected_gray.png -------------------------------------------------------------------------------- /src/demoapp/res/texture/main/default_hd_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunka/cocos2dx-lua-ui-editor/HEAD/src/demoapp/res/texture/main/default_hd_avatar.png -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_dialogtest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = false, 3 | _id = "DialogTest", 4 | _type = "DialogTest", 5 | height = "$fill", 6 | ignoreAnchor = 0, 7 | width = "$fill"} -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_api_apitest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = false, 3 | _id = "APITest", 4 | _type = "APITest", 5 | height = "$fill", 6 | ignoreAnchor = 0, 7 | popOnBack = 1, 8 | width = "$fill"} -------------------------------------------------------------------------------- /src/gk/fsm/init.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 20/12/2017 5 | -- Time: 10:35 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | gk.FSMEditor = import(".FSMEditor") -------------------------------------------------------------------------------- /src/gk/action/init.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 7/19/17 5 | -- Time: 11:35 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | gk.BreathAction = import(".BreathAction") 10 | -------------------------------------------------------------------------------- /src/gk/res/data/default.tsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /res/3d/cube_map.frag: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | varying vec3 v_reflect; 6 | uniform samplerCube u_cubeTex; 7 | uniform vec4 u_color; 8 | 9 | void main(void) 10 | { 11 | gl_FragColor = textureCube(u_cubeTex, v_reflect) * u_color; 12 | } 13 | -------------------------------------------------------------------------------- /src/gk/test/model/model.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/5/17 5 | -- Time: 17:18 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local model = {} 10 | 11 | model.diamondCount = 1000 12 | 13 | return model -------------------------------------------------------------------------------- /src/demoapp/ChatCell.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/22 5 | -- Time: 下午11:08 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ChatCell = class("ChatCell", gk.TableViewCell) 10 | 11 | return ChatCell -------------------------------------------------------------------------------- /src/config.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 7/20/17 5 | -- Time: 09:37 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | DEBUG = 2 10 | 11 | -- use framework, will disable all deprecated API, false - use legacy API 12 | CC_USE_FRAMEWORK = true 13 | -------------------------------------------------------------------------------- /src/gk/controller/init.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/12/29 5 | -- Time: 上午10:12 6 | -- To change this template use File | Settings | File Templates. 7 | 8 | gk.SceneManager = import(".SceneManager") 9 | gk.resource = import(".resource") 10 | gk.shader = import(".shader") -------------------------------------------------------------------------------- /src/demoapp/gen/value/strings_cn.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/18 5 | -- Time: 下午2:56 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | return { 10 | app_name = "微信", 11 | chats = "微信", 12 | contacts = "联系人", 13 | discover = "发现", 14 | me = "我", 15 | } 16 | 17 | -------------------------------------------------------------------------------- /src/gk/core/log.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/12/29 5 | -- Time: 上午10:12 6 | -- To change this template use File | Settings | File Templates. 7 | 8 | local function log(format, ...) 9 | local string = string.format(format, ...) 10 | print(string) 11 | return string 12 | end 13 | 14 | gk.log = log 15 | -------------------------------------------------------------------------------- /src/gk/res/shader/Highlight.fsh: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | varying vec4 v_fragmentColor; 6 | varying vec2 v_texCoord; 7 | 8 | void main() 9 | { 10 | gl_FragColor = texture2D(CC_Texture0, v_texCoord) * v_fragmentColor; 11 | if(gl_FragColor.a > 0.0) { 12 | gl_FragColor.rgb *= 1.3; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/gk/test/ShaderTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/21/17 5 | -- Time: 14:43 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ShaderTest = class("ShaderTest", gk.Layer) 10 | 11 | function ShaderTest:ctor() 12 | ShaderTest.super.ctor(self) 13 | end 14 | 15 | return ShaderTest -------------------------------------------------------------------------------- /src/gk/test/fsm/GameFSM.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 19/12/2017 5 | -- Time: 21:28 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local GameFSM = class("GameFSM", gk.FSMEditor) 10 | 11 | function GameFSM:ctor(...) 12 | GameFSM.super.ctor(self, ...) 13 | end 14 | 15 | return GameFSM -------------------------------------------------------------------------------- /src/gk/test/DrawNodeTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 31/08/2017 5 | -- Time: 16:02 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNodeTest = class("DrawNodeTest", gk.Layer) 10 | 11 | function DrawNodeTest:ctor() 12 | DrawNodeTest.super.ctor(self) 13 | end 14 | 15 | return DrawNodeTest -------------------------------------------------------------------------------- /src/demoapp/gen/value/strings.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/18 5 | -- Time: 下午2:56 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | return { 10 | app_name = "WeChat", 11 | chats = "Chats", 12 | contacts = "Contacts", 13 | discover = "Discover", 14 | me = "Me", 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/gk/tools/init.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 30/11/2017 5 | -- Time: 14:52 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | gk.config = import(".config") 10 | gk.util = import(".util") 11 | gk.profile = import(".profile") 12 | gk.scheduler = import(".scheduler") 13 | gk.ErrorReporter = import(".ErrorReporter") 14 | 15 | -------------------------------------------------------------------------------- /src/gk/res/shader/Mvp.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 a_position; 2 | attribute vec2 a_texCoord; 3 | attribute vec4 a_color; 4 | 5 | #ifdef GL_ES 6 | varying lowp vec4 v_fragmentColor; 7 | varying mediump vec2 v_texCoord; 8 | #else 9 | varying vec4 v_fragmentColor; 10 | varying vec2 v_texCoord; 11 | #endif 12 | 13 | void main() 14 | { 15 | gl_Position = CC_MVPMatrix * a_position; 16 | v_fragmentColor = a_color; 17 | v_texCoord = a_texCoord; 18 | } -------------------------------------------------------------------------------- /src/gk/test/NodeTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/3/1 5 | -- Time: 下午9:26 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local NodeTest = class("NodeTest", gk.Layer) 10 | 11 | function NodeTest:ctor() 12 | NodeTest.super.ctor(self) 13 | gk.util:drawNodeBounds(self.layer1, nil, -3) 14 | gk.util:drawNodeBounds(self.scrollView1, nil, -3) 15 | end 16 | 17 | return NodeTest -------------------------------------------------------------------------------- /src/gk/res/shader/NoMvp.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 a_position; 2 | attribute vec2 a_texCoord; 3 | attribute vec4 a_color; 4 | 5 | #ifdef GL_ES 6 | varying lowp vec4 v_fragmentColor; 7 | varying mediump vec2 v_texCoord; 8 | #else 9 | varying vec4 v_fragmentColor; 10 | varying vec2 v_texCoord; 11 | #endif 12 | 13 | void main() 14 | { 15 | gl_Position = CC_PMatrix * a_position; 16 | v_fragmentColor = a_color; 17 | v_texCoord = a_texCoord; 18 | } 19 | -------------------------------------------------------------------------------- /src/gk/node/TableViewCell.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/7 5 | -- Time: 下午12:35 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local TableViewCell = class("TableViewCell", function() 10 | return cc.TableViewCell:create() 11 | end) 12 | 13 | -- must have a __cname and ctor to be injected 14 | function TableViewCell:ctor() 15 | self:enableNodeEvents() 16 | end 17 | 18 | return TableViewCell -------------------------------------------------------------------------------- /src/gk/tools/profile.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 7/12/17 5 | -- Time: 13:53 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local profile = {} 10 | 11 | function profile:start(key, ...) 12 | if self.onStart then 13 | self.onStart(key, ...) 14 | end 15 | end 16 | 17 | function profile:stop(key, ...) 18 | if self.onStop then 19 | self.onStop(key, ...) 20 | end 21 | end 22 | 23 | return profile 24 | -------------------------------------------------------------------------------- /res/3d/cube_map.vert: -------------------------------------------------------------------------------- 1 | attribute vec4 a_position; 2 | attribute vec3 a_normal; 3 | 4 | varying vec3 v_reflect; 5 | 6 | void main(void) 7 | { 8 | gl_Position = CC_MVPMatrix * a_position; 9 | 10 | // compute reflect 11 | vec4 positionWorldViewSpace = CC_MVMatrix * a_position; 12 | vec3 vEyeVertex = normalize(positionWorldViewSpace.xyz); 13 | 14 | vec3 v_normalVector = CC_NormalMatrix * a_normal; 15 | v_reflect = normalize(reflect(-vEyeVertex, v_normalVector)); 16 | } 17 | -------------------------------------------------------------------------------- /src/gk/res/data/default.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | eJwNwwUSgkAAAMAzEQOwUCzExPb/r2N3ZlshhLYdu/bsGzkwdujIsRMTUzOnzpy7cGnuyrWFG7fu3Huw9GjlybMXr968W/vw6cu3H7/+/NsAMw8EmQ== 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/gk/test/dialog/Dialog1.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/21/17 5 | -- Time: 13:52 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local Dialog1 = class("Dialog1", gk.Dialog) 10 | 11 | function Dialog1:ctor() 12 | Dialog1.super.ctor(self) 13 | end 14 | 15 | function Dialog1:onCancelClicked() 16 | self:pop() 17 | end 18 | 19 | function Dialog1:onConfirmClicked() 20 | self:showDialog("gk.test.dialog.Dialog1") 21 | end 22 | 23 | return Dialog1 -------------------------------------------------------------------------------- /src/gk/node/Widget.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/5/17 5 | -- Time: 10:28 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local Widget = class("Widget", function() 10 | return cc.Node:create() 11 | end) 12 | Widget._isWidget = true 13 | 14 | -- must have a __cname and ctor to be injected 15 | function Widget:ctor() 16 | self:enableNodeEvents() 17 | end 18 | 19 | function Widget:registerCustomProp(...) 20 | gk.injector:registerCustomProp(self, ...) 21 | end 22 | 23 | return Widget -------------------------------------------------------------------------------- /src/gk/test/widget/PopupBg.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 13/03/2018 5 | -- Time: 14:31 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local PopupBg = class("PopupBg", gk.Widget) 10 | 11 | function PopupBg:ctor() 12 | PopupBg.super.ctor(self) 13 | end 14 | 15 | function PopupBg:onEnter() 16 | -- auto set position 17 | local size = self:getContentSize() 18 | self.bg:setContentSize(size) 19 | self.bg:setPosition(cc.p(size.width / 2, size.height / 2)) 20 | end 21 | 22 | return PopupBg -------------------------------------------------------------------------------- /src/gk/res/shader/Freeze.fsh: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | varying vec2 v_texCoord; 6 | varying vec4 v_fragmentColor; 7 | 8 | void main(void) 9 | { 10 | vec4 normalColor = texture2D(CC_Texture0, v_texCoord) * v_fragmentColor; 11 | float dt = CC_SinTime.w; 12 | float time = dt > 0.0 ? dt : -CC_SinTime.w; 13 | time = (time > 0.96 && dt > 0.0) ? (time*1.2) : (time/10.0 + 0.96); 14 | normalColor *= vec4(1.0-0.2*time, 1.0 +0.25*time, 1.0+0.25*time, 1.0 +0.25*time); 15 | normalColor.b += normalColor.a * 0.4*time; 16 | gl_FragColor = normalColor; 17 | } 18 | -------------------------------------------------------------------------------- /src/gk/test/LabelTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/10 5 | -- Time: 下午9:34 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local LabelTest = class("LabelTest", gk.Layer) 10 | 11 | function LabelTest:ctor() 12 | LabelTest.super.ctor(self) 13 | local color = cc.c4f(128 / 255, 128 / 255, 0, 100 / 255) 14 | for _, child in pairs(self:getChildren()) do 15 | if gk.util:instanceof(child, "cc.Label") and child:getDimensions().width > 0 then 16 | gk.util:drawNodeBounds(child, color, -3) 17 | end 18 | end 19 | end 20 | 21 | return LabelTest -------------------------------------------------------------------------------- /src/gk/node/CheckBox.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/12/17 5 | -- Time: 14:30 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local SpriteButton = import(".SpriteButton") 10 | local CheckBox = class("CheckBox", SpriteButton) 11 | 12 | function CheckBox:ctor(...) 13 | CheckBox.super.ctor(self, ...) 14 | self.autoSelected = false 15 | end 16 | 17 | function CheckBox:onTouchEnded(touch, event) 18 | if self.trackingTouch then 19 | self:setSelected(not self.selected) 20 | end 21 | CheckBox.super.onTouchEnded(self, touch, event) 22 | end 23 | 24 | return CheckBox -------------------------------------------------------------------------------- /src/gk/test/DialogTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 5/24/17 5 | -- Time: 15:54 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DialogTest = class("DialogTest", gk.Layer) 10 | 11 | function DialogTest:ctor() 12 | DialogTest.super.ctor(self) 13 | 14 | local dialog = self:showDialog("gk.test.dialog.Dialog1") 15 | dialog.popupBg1.label1:setString("Dialog can be added into Layer or Dialog.\nClick confirm to add Dialog in Dialog.\nClick cancel to pop.") 16 | dialog.onPopCallback = function() 17 | gk.log("on pop") 18 | end 19 | end 20 | 21 | return DialogTest -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_api_shadertest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = false, 3 | _id = "shaderTest1", 4 | _type = "ShaderTest", 5 | height = "$fill", 6 | width = "$fill", 7 | _children = { { 8 | _id = "label1", 9 | _type = "cc.Label", 10 | fontSize = 18, 11 | height = 0, 12 | scaleX = "$minScale", 13 | scaleY = "$minScale", 14 | string = "None", 15 | width = 0, 16 | x = 60, 17 | y = 680, 18 | anchor = { 19 | x = 0, 20 | y = 0.5}, 21 | fontFile = { 22 | en = "Arial"}, 23 | scaleXY = { 24 | x = "$scaleX", 25 | y = "$scaleY"}}}} -------------------------------------------------------------------------------- /src/demoapp/gen/layout/demoapp_splashlayer.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _id = "SplashLayer", 3 | _type = "SplashLayer", 4 | enableKeyPad = 1, 5 | height = "$fill", 6 | ignoreAnchor = 0, 7 | popOnBack = 1, 8 | width = "$fill", 9 | _children = { { 10 | _fold = true, 11 | _id = "sprite1", 12 | _type = "cc.Sprite", 13 | file = "splash/arc.jpg", 14 | flippedX = 1, 15 | ignoreAnchor = 1, 16 | scaleX = "$minScale", 17 | scaleY = "$minScale", 18 | x = 360, 19 | y = 640, 20 | blendFunc = { 21 | dst = 771, 22 | src = 770}, 23 | scaleXY = { 24 | x = "$scaleX", 25 | y = "$scaleY"}}}} -------------------------------------------------------------------------------- /src/gk/gen/config.lua: -------------------------------------------------------------------------------- 1 | return { 2 | genNodes = { 3 | ErrorReportDialog = { 4 | cname = "ErrorReportDialog", 5 | genPath = "gk/gen/layout/gk_layout_errorreportdialog.lua", 6 | genSrcPath = "gk/layout/", 7 | path = "gk/layout/ErrorReportDialog"}, 8 | FSMNode = { 9 | cname = "FSMNode", 10 | genPath = "gk/gen/layout/gk_layout_fsmnode.lua", 11 | genSrcPath = "gk/layout/", 12 | isWidget = true, 13 | path = "gk/layout/FSMNode"}, 14 | FSMTransNode = { 15 | cname = "FSMTransNode", 16 | genPath = "gk/gen/layout/gk_layout_fsmtransnode.lua", 17 | genSrcPath = "gk/layout/", 18 | isWidget = true, 19 | path = "gk/layout/FSMTransNode"}}} -------------------------------------------------------------------------------- /src/gk/layout/ErrorReportDialog.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 18/12/2017 5 | -- Time: 19:00 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ErrorReportDialog = class("ErrorReportDialog", gk.Dialog) 10 | 11 | function ErrorReportDialog:ctor() 12 | ErrorReportDialog.super.ctor(self) 13 | self:addMaskLayer() 14 | self:animateOut() 15 | end 16 | 17 | function ErrorReportDialog:setTitle(title) 18 | self.dialogBg.titleLabel:setString(title) 19 | return self 20 | end 21 | 22 | function ErrorReportDialog:setContent(content) 23 | self.contentLabel:setString(content) 24 | return self 25 | end 26 | 27 | return ErrorReportDialog -------------------------------------------------------------------------------- /src/demoapp/gen/config.lua: -------------------------------------------------------------------------------- 1 | return { 2 | fontDir = "demoapp/res/font/", 3 | genDir = "demoapp/gen/", 4 | shaderDir = "demoapp/shader/", 5 | fontFiles = {}, 6 | genNodes = { 7 | ChatCell = { 8 | cname = "ChatCell", 9 | genPath = "demoapp/gen/layout/demoapp_chatcell.lua", 10 | genSrcPath = "demoapp/", 11 | path = "demoapp/ChatCell"}, 12 | MainLayer = { 13 | cname = "MainLayer", 14 | genPath = "demoapp/gen/layout/demoapp_mainlayer.lua", 15 | genSrcPath = "demoapp/", 16 | path = "demoapp/MainLayer"}, 17 | SplashLayer = { 18 | cname = "SplashLayer", 19 | genPath = "demoapp/gen/layout/demoapp_splashlayer.lua", 20 | genSrcPath = "demoapp/", 21 | path = "demoapp/SplashLayer"}}} -------------------------------------------------------------------------------- /src/demoapp/SplashLayer.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/18 5 | -- Time: 下午2:52 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local SplashLayer = class("SplashLayer", gk.Layer) 10 | 11 | function SplashLayer:ctor() 12 | SplashLayer.super.ctor(self) 13 | 14 | if self.sprite1 then 15 | local size = self.sprite1:getContentSize() 16 | self.sprite1:setScale(gk.display.winSize().width / size.width) 17 | end 18 | 19 | if gk.mode ~= gk.MODE_EDIT then 20 | self:runAction(cc.Sequence:create(cc.DelayTime:create(1.5), cc.CallFunc:create(function() 21 | gk.SceneManager:replace("demoapp.MainLayer") 22 | end))) 23 | end 24 | end 25 | 26 | return SplashLayer -------------------------------------------------------------------------------- /src/gk/test/ParticleSystemTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/20/17 5 | -- Time: 16:39 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ParticleSystemTest = class("ParticleSystemTest", gk.Layer) 10 | 11 | function ParticleSystemTest:ctor() 12 | ParticleSystemTest.super.ctor(self) 13 | 14 | self.sprite1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.MoveBy:create(2, cc.p(0, 500 * gk.display:minScale())), 15 | cc.MoveBy:create(2, cc.p(0, -500 * gk.display:minScale()))))) 16 | self.particleSystemQuad2:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.MoveBy:create(2, cc.p(0, 500 * gk.display:minScale())), 17 | cc.MoveBy:create(2, cc.p(0, -500 * gk.display:minScale()))))) 18 | end 19 | 20 | return ParticleSystemTest -------------------------------------------------------------------------------- /src/gk/layout/FSMNode.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 19/12/2017 5 | -- Time: 17:57 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local FSMNode = class("FSMNode", gk.Widget) 10 | 11 | function FSMNode:ctor(...) 12 | self.state = "" 13 | self:registerCustomProp("state", "string") 14 | self:registerCustomProp("default", "bool") 15 | FSMNode.super.ctor(self, ...) 16 | end 17 | 18 | function FSMNode:setState(state) 19 | self.state = state 20 | if self.nameLabel then 21 | self.nameLabel:setString(((self.default and self.default == 0) and "*" or "") .. self.state) 22 | end 23 | end 24 | 25 | function FSMNode:setSelected(select) 26 | self.layerColor1:setColor(select and cc.c3b(151, 205, 0) or cc.c3b(153, 153, 153)) 27 | end 28 | 29 | return FSMNode 30 | -------------------------------------------------------------------------------- /src/gk/editor/init.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 5/19/17 5 | -- Time: 14:37 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | gk.theme = import(".theme") 10 | gk.editorConfig = import(".editorConfig") 11 | gk.editorPanel = import(".editorPanel") 12 | ----------------------------- 3d ----------------------------------- 13 | import(".config3d"):register(gk.editorConfig) 14 | 15 | -- attach editor panel to editing scene 16 | gk.editorPanel.attachToScene = function(_, scene) 17 | gk.log("attach editorPanel to Scene") 18 | scene:addChild(gk.editorPanel.create(scene), 9999999, -99999) 19 | local c4b = gk.theme.config.backgroundColor 20 | gk.util:drawNodeBg(scene, gk.util:c4b2c4f(c4b), -89) 21 | end 22 | 23 | gk.editorPanel.getPanel = function(_, scene) 24 | return scene:getChildByTag(-99999) 25 | end 26 | -------------------------------------------------------------------------------- /src/gk/node/DrawPoint.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 03/09/2017 5 | -- Time: 12:09 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNode = import(".DrawNode") 10 | local DrawPoint = class("DrawPoint", DrawNode) 11 | 12 | function DrawPoint:ctor() 13 | DrawPoint.super.ctor(self) 14 | 15 | self:addProperty("pointSize", 10) 16 | self:addBoolProperty("dot", false) 17 | end 18 | 19 | function DrawPoint:draw() 20 | DrawPoint.super.draw(self) 21 | self:setContentSize(cc.size(self.pointSize, self.pointSize)) 22 | if self.dot then 23 | self.child:drawDot(cc.p(self.pointSize / 2, self.pointSize / 2), self.pointSize, self.c4f) 24 | else 25 | self.child:drawPoint(cc.p(self.pointSize / 2, self.pointSize / 2), self.pointSize, self.c4f) 26 | end 27 | end 28 | 29 | return DrawPoint -------------------------------------------------------------------------------- /src/gk/gen/layout/gk_layout_fsmnode.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = false, 3 | _id = "fSMNode1", 4 | height = 30, 5 | width = 100, 6 | x = 640, 7 | y = 360, 8 | anchor = { 9 | x = 0.5, 10 | y = 0.5}, 11 | _children = { { 12 | _id = "layerColor1", 13 | _lock = 0, 14 | _type = "cc.LayerColor", 15 | color = "999999ff", 16 | height = "$fill", 17 | ignoreAnchor = 1, 18 | width = "$fill", 19 | x = 50, 20 | y = 15, 21 | _children = { { 22 | _id = "nameLabel", 23 | _lock = 0, 24 | _type = "cc.Label", 25 | fontSize = 36, 26 | hAlign = 1, 27 | overflow = 2, 28 | scaleX = 0.5, 29 | scaleY = 0.5, 30 | string = "label", 31 | textColor = "141414ff", 32 | vAlign = 1, 33 | width = 180, 34 | x = 50, 35 | y = 15}}}}} -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_widget_textbutton.lua: -------------------------------------------------------------------------------- 1 | return { 2 | TextButton_labelString = "", 3 | _fold = true, 4 | _id = "textButton1", 5 | height = 50, 6 | width = 150, 7 | x = 640, 8 | y = 360, 9 | anchor = { 10 | x = 0.5, 11 | y = 0.5}, 12 | _children = { { 13 | _id = "button1", 14 | _type = "ZoomButton", 15 | x = 100, 16 | y = 25, 17 | _children = { { 18 | _id = "scale9Sprite1", 19 | _lock = 0, 20 | _type = "ccui.Scale9Sprite", 21 | file = "gk/res/texture/btn_bg.png", 22 | height = 50, 23 | width = 150, 24 | x = -12, 25 | y = 53, 26 | capInsets = { 27 | height = 16.667, 28 | width = 50, 29 | x = 50, 30 | y = 16.667}, 31 | _children = { { 32 | _id = "label1", 33 | _type = "cc.Label", 34 | fontSize = 18, 35 | string = "label", 36 | x = 86, 37 | y = 37}}}}}}} -------------------------------------------------------------------------------- /src/gk/node/DrawLine.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 03/09/2017 5 | -- Time: 12:32 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNode = import(".DrawNode") 10 | local DrawLine = class("DrawLine", DrawNode) 11 | 12 | function DrawLine:ctor() 13 | DrawLine.super.ctor(self) 14 | 15 | self:addProperty("from", cc.p(0, 0)) 16 | self:addProperty("to", cc.p(100, 50)) 17 | self:addProperty("radius", 5) 18 | self:addBoolProperty("segment", false) 19 | end 20 | 21 | function DrawLine:draw() 22 | DrawLine.super.draw(self) 23 | if self.segment then 24 | self.child:drawSegment(self.from, self.to, self.radius, self.c4f) 25 | else 26 | self.child:drawLine(self.from, self.to, self.c4f) 27 | end 28 | end 29 | 30 | function DrawLine:getMovablePoints() 31 | return { self.from, self.to } 32 | end 33 | 34 | function DrawLine:setMovablePoints(p, index) 35 | if index == 1 then 36 | self.from = p 37 | elseif index == 2 then 38 | self.to = p 39 | end 40 | 41 | self:draw() 42 | end 43 | 44 | 45 | return DrawLine -------------------------------------------------------------------------------- /src/gk/node/DrawCardinalSpline.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 31/08/2017 5 | -- Time: 17:36 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNode = import(".DrawNode") 10 | local DrawCardinalSpline = class("DrawCardinalSpline", DrawNode) 11 | 12 | function DrawCardinalSpline:ctor() 13 | DrawCardinalSpline.super.ctor(self) 14 | self:addProperty("tension", 0.5) 15 | self:addProperty("points", { cc.p(0, 0), cc.p(50, 25), cc.p(100, 0), cc.p(150, 25) }) 16 | self:addProperty("segments", 50) 17 | self.pointsNum = 4 18 | end 19 | 20 | function DrawCardinalSpline:getPointsNum() 21 | return self.pointsNum 22 | end 23 | 24 | function DrawCardinalSpline:setPointsNum(pointsNum) 25 | self.pointsNum = pointsNum 26 | while #self.points < self.pointsNum do 27 | table.insert(self.points, cc.p(0, 0)) 28 | end 29 | self:draw() 30 | end 31 | 32 | function DrawCardinalSpline:draw() 33 | DrawCardinalSpline.super.draw(self) 34 | self.child:drawCardinalSpline(self.points, self.tension, self.segments, self.c4f) 35 | end 36 | 37 | return DrawCardinalSpline -------------------------------------------------------------------------------- /src/gk/test/fsm/FSMTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 20/12/2017 5 | -- Time: 14:51 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local FSMTest = class("FSMTest", gk.Layer) 10 | 11 | function FSMTest:ctor() 12 | FSMTest.super.ctor(self) 13 | 14 | local fsm = gk.injector:inflateFSM("gk.test.fsm.GameFSM") 15 | fsm.onStart = function() 16 | gk.log("onStart") 17 | end 18 | fsm.onPause = function() 19 | gk.log("onPause") 20 | end 21 | fsm.onResume = function() 22 | gk.log("onResume") 23 | end 24 | fsm.onWin = function() 25 | gk.log("onWin") 26 | end 27 | fsm.onLose = function() 28 | gk.log("onLose") 29 | end 30 | fsm.onReset = function() 31 | gk.log("onReset") 32 | end 33 | 34 | gk.log(fsm:getState()) 35 | gk.log(fsm:is("INIT")) 36 | gk.log(fsm:win()) 37 | gk.log(fsm:start()) 38 | gk.log(fsm:pause()) 39 | gk.log(fsm:resume()) 40 | gk.log(fsm:win()) 41 | gk.log(fsm:reset()) 42 | gk.log(fsm:start()) 43 | gk.log(fsm:lose()) 44 | end 45 | 46 | return FSMTest -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_widget_popupbg.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _id = "popupBg1", 3 | height = 350, 4 | ignoreAnchor = 1, 5 | scaleX = "$minScale", 6 | scaleY = "$minScale", 7 | width = 600, 8 | x = 640, 9 | y = 360, 10 | anchor = { 11 | x = 0.5, 12 | y = 0.5}, 13 | scaleXY = { 14 | x = "$scaleX", 15 | y = "$scaleY"}, 16 | _children = { { 17 | _id = "bg", 18 | _type = "cc.LayerGradient", 19 | height = "$fill", 20 | ignoreAnchor = 1, 21 | width = "$fill", 22 | x = 435, 23 | y = 244.6875, 24 | endColor = { 25 | a = 255, 26 | b = 255, 27 | g = 255, 28 | r = 255}, 29 | startColor = { 30 | a = 255, 31 | b = 200, 32 | g = 200, 33 | r = 200}, 34 | _children = { { 35 | _id = "label1", 36 | _type = "cc.Label", 37 | color = "323232", 38 | fontSize = 18, 39 | string = "@some_text", 40 | width = 480, 41 | x = 300, 42 | y = 299, 43 | anchor = { 44 | x = 0.5, 45 | y = 1}}}}}} -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_tableviewtest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = false, 3 | _id = "TableViewTest", 4 | _type = "TableViewTest", 5 | height = "$fill", 6 | ignoreAnchor = 0, 7 | popOnBack = 1, 8 | width = "$fill", 9 | _children = { { 10 | _id = "layerColor1", 11 | _lock = 0, 12 | _type = "cc.LayerColor", 13 | color = "999999ff", 14 | height = 0, 15 | scaleX = "$minScale", 16 | scaleY = "$minScale", 17 | width = 480, 18 | anchor = { 19 | x = 0, 20 | y = 0}, 21 | _children = { { 22 | _fold = true, 23 | _id = "tableView1", 24 | _type = "cc.TableView", 25 | cellAtIndex = "&cellAtIndex", 26 | cellNums = "&cellNumForTable", 27 | cellSizeForIndex = "&cellSizeForTable", 28 | direction = 1, 29 | height = 0, 30 | ignoreAnchor = 1, 31 | verticalFillOrder = 0, 32 | width = 0, 33 | anchor = { 34 | x = 0, 35 | y = 0}, 36 | viewSize = { 37 | height = 0, 38 | width = "$fill"}}}}}} -------------------------------------------------------------------------------- /src/gk/test/ProgressTimerTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/22 5 | -- Time: 下午2:32 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ProgressTimerTest = class("ProgressTimerTest", gk.Layer) 10 | 11 | function ProgressTimerTest:ctor() 12 | ProgressTimerTest.super.ctor(self) 13 | 14 | self.progressTimer1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.ProgressTo:create(2, 100), cc.ProgressTo:create(2, 0)))) 15 | self.progressTimer2:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.ProgressTo:create(2, 100), cc.ProgressTo:create(2, 0)))) 16 | self.progressTimer3:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.ProgressTo:create(2, 100), cc.ProgressTo:create(2, 0)))) 17 | self.progressTimer4:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.ProgressTo:create(2, 100), cc.ProgressTo:create(2, 0)))) 18 | 19 | gk.util:drawNodeBounds(self.progressTimer1, nil, -3) 20 | gk.util:drawNodeBounds(self.progressTimer2, nil, -3) 21 | gk.util:drawNodeBounds(self.progressTimer3, nil, -3) 22 | gk.util:drawNodeBounds(self.progressTimer4, nil, -3) 23 | end 24 | 25 | return ProgressTimerTest -------------------------------------------------------------------------------- /src/gk/test/gen/value/strings_cn.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 17/1/19 5 | -- Time: 上午10:10 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | return { 10 | confirm = "确定", 11 | cancel = "取消", 12 | multi_language = "不同语言使用不同字体文件(英文:Klee.fnt,中文:Arial)。", 13 | zoom_button = "普通按钮", 14 | zoom_button_desc = "缩放按钮的大小由第一个child决定不能更改,child可以是任意类型node。(变更child大小后需要F1刷新一下,自动刷新暂未实现)", 15 | sprite_button = "图片按钮", 16 | sprite_button_desc = "图片按钮使用3张图片代表3个状态Normal, Selected(点击临时状态不能保持), Disabled;有2种选中模式,切换:切换状态时切换图片;叠加:切换状态时Normal图片不变,叠加Selected或者Disabled图片。", 17 | toggle_button = "Toggle按钮", 18 | toggle_button_desc = "Toggle按钮使用Tag控制child切换显示,所有tag等于SelectedTag的child为visible状态,大小跟普通按钮一样由第一个child决定。", 19 | check_box = "CheckBox", 20 | check_box_desc = "CheckBox继承于SpriteButton,点击会自动切换Selected状态(可以保持)。", 21 | some_text = "When a country Taxes our products coming in at, say, 50%, and we Tax the same product coming into our country at ZERO, not fair or smart. We\ 22 | will soon be starting RECIPROCAL TAXES so that we will charge the same thing as they charge us. $800 Billion Trade Deficit-have no choice!", 23 | } -------------------------------------------------------------------------------- /src/gk/test/ButtonTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 5/18/17 5 | -- Time: 15:31 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ButtonTest = class("ButtonTest", gk.Layer) 10 | 11 | function ButtonTest:ctor() 12 | ButtonTest.super.ctor(self) 13 | end 14 | 15 | function ButtonTest:onZoomBtnClicked(button) 16 | gk.log("onZoomBtnClicked") 17 | end 18 | 19 | function ButtonTest:onZoomBtnLongPressed(button) 20 | gk.log("onZoomBtnLongPressed") 21 | end 22 | 23 | function ButtonTest:onSpriteBtnClicked(button) 24 | gk.log("onSpriteBtnClicked") 25 | end 26 | 27 | function ButtonTest:onSpriteBtnSelectChanged(button, selected) 28 | gk.log("onSpriteBtnSelectChanged %s", selected) 29 | end 30 | 31 | function ButtonTest:onSpriteBtnEnableChanged(button, enabled) 32 | gk.log("onSpriteBtnEnableChanged %s", enabled) 33 | end 34 | 35 | function ButtonTest:onSelectedTagChanged(button, tag) 36 | gk.log("onSelectedTagChanged %d", tag) 37 | if tag >= 1 and tag <= 3 then 38 | local colors = { cc.c3b(255, 255, 255), cc.c3b(0, 255, 0), cc.c3b(0, 0, 255) } 39 | self.label3:setColor(colors[tag]) 40 | end 41 | end 42 | 43 | return ButtonTest -------------------------------------------------------------------------------- /src/gk/editor/config3d.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 24/11/2017 5 | -- Time: 22:11 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local config3D = {} 10 | 11 | function config3D:register(config) 12 | config:registerPlaneProp("_is3d", false) 13 | config:registerEditableProp("z", function(_) return 0 end, 14 | function(node, var) node:setPositionZ(var) end) 15 | config:registerFloatProp("scaleZ") 16 | config:registerProp("rotation3D") 17 | 18 | ----------------------------- cc.Sprite3D ----------------------------------- 19 | config:registerSupportNode({ _type = "cc.Sprite3D", modelPath = "gk/res/3d/orc.c3b", _is3d = true, _internal = true }) 20 | config:registerPlaneProp("modelPath") 21 | config:registerDisplayProps({ 22 | _type = "cc.Sprite3D", 23 | stringProps = { 24 | { key = "modelPath" }, 25 | }, 26 | -- boolProps = {}, 27 | }) 28 | config:registerNodeCreator("cc.Sprite3D", function(info, rootTable) 29 | local node = cc.Sprite3D:create(info.modelPath) 30 | info._id = info._id or config:genID("sprite3D", rootTable) 31 | return node 32 | end) 33 | end 34 | 35 | return config3D -------------------------------------------------------------------------------- /src/gk/node/DrawNodeCircle.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 15/08/2017 5 | -- Time: 21:03 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNode = import(".DrawNode") 10 | local DrawNodeCircle = class("DrawNodeCircle", DrawNode) 11 | 12 | function DrawNodeCircle:ctor() 13 | DrawNodeCircle.super.ctor(self) 14 | 15 | self:addProperty("radius", 100) 16 | self:addProperty("angle", 0) 17 | self:addProperty("segments", 50) 18 | self:addBoolProperty("drawLineToCenter", false) 19 | self:addBoolProperty("solid", false) 20 | end 21 | 22 | function DrawNodeCircle:draw() 23 | DrawNodeCircle.super.draw(self) 24 | self:setContentSize(cc.size(self.radius * 2, self.radius * 2)) 25 | if gk.mode == gk.MODE_EDIT then 26 | -- draw control points 27 | self.child:drawPoint(cc.p(self.radius, self.radius), 5, cc.c4f(1, 0, 0, 0.5)) 28 | end 29 | if self.solid then 30 | self.child:drawSolidCircle(cc.p(self.radius, self.radius), self.radius, self.angle, self.segments, self.c4f) 31 | else 32 | self.child:drawCircle(cc.p(self.radius, self.radius), self.radius, self.angle, self.segments, self.drawLineToCenter, self.c4f) 33 | end 34 | end 35 | 36 | return DrawNodeCircle -------------------------------------------------------------------------------- /src/gk/editor/theme.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 7/14/17 5 | -- Time: 14:09 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local theme = {} 10 | 11 | --- fonts 12 | theme.font_ttf = "gk/res/font/Consolas.ttf" -- for editBox 13 | theme.font_fnt = "gk/res/font/Consolas.fnt" -- for display 14 | theme.font_sys = "Consolas" -- for auto complete 15 | 16 | --- colors 17 | theme.configs = { 18 | DRAK_GRAY = { 19 | backgroundColor = cc.c4b(60, 63, 65, 255), 20 | fontColorNormal = cc.c3b(189, 189, 189), 21 | }, 22 | LIGHT_WHITE = { 23 | backgroundColor = cc.c4b(242, 242, 242, 255), 24 | fontColorNormal = cc.c3b(189, 189, 189), 25 | }, 26 | } 27 | theme.themeName = cc.UserDefault:getInstance():getStringForKey("gk_themeName", "DRAK_GRAY") 28 | theme.config = theme.configs[theme.themeName] or theme.configs["DRAK_GRAY"] 29 | 30 | function theme:setTheme(themeName) 31 | if self.themeName ~= themeName and self.configs[themeName] then 32 | self.themeName = themeName 33 | cc.UserDefault:getInstance():setStringForKey("gk_themeName", self.themeName) 34 | cc.UserDefault:getInstance():flush() 35 | gk.util:restartGame(gk.mode) 36 | end 37 | end 38 | 39 | return theme -------------------------------------------------------------------------------- /src/gk/init.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/12/29 5 | -- Time: 上午10:12 6 | -- To change this template use File | Settings | File Templates. 7 | 8 | gk = {} 9 | gk.MODE_EDIT = 1 -- KEY_F1: debug mode, restart with current editing entry 10 | gk.MODE_RELEASE_CURRENT = 2 -- KEY_F2: release mode, restart with current entry 11 | gk.MODE_RELEASE = 0 -- KEY_F3: release mode, restart with default entry 12 | 13 | gk.mode = gk.MODE_RELEASE 14 | gk.defaultSpriteDebug = "gk/res/texture/default_debug.png" 15 | gk.defaultSpriteRelease = "gk/res/texture/default_release.png" 16 | gk.errorOccurs = false -- disable sync when error occurs 17 | gk.displayRuntimeVersion = true -- display runtime version on scene's right-bottom corner 18 | gk.exNodeDisplayer = {} -- for custom nodes 19 | 20 | -- export global variable 21 | local __g = _G 22 | gk.exports = {} 23 | setmetatable(gk.exports, { 24 | __newindex = function(_, name, value) 25 | rawset(__g, name, value) 26 | end, 27 | __index = function(_, name) 28 | return rawget(__g, name) 29 | end 30 | }) 31 | 32 | require "gk.core.init" 33 | require "gk.action.init" 34 | require "gk.node.init" 35 | require "gk.fsm.init" 36 | require "gk.controller.init" 37 | require "gk.editor.init" 38 | require "gk.tools.init" -------------------------------------------------------------------------------- /src/gk/test/ClippingNodeTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/22 5 | -- Time: 上午11:34 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ClippingNodeTest = class("ClippingNodeTest", gk.Layer) 10 | 11 | function ClippingNodeTest:ctor() 12 | ClippingNodeTest.super.ctor(self) 13 | 14 | -- set stencil 15 | if self.clippingNode1 then 16 | local stencil = gk.create_sprite("stencil.png") 17 | local size = self.clippingNode1:getContentSize() 18 | stencil:setPosition(cc.p(size.width / 2, size.height / 2)) 19 | stencil:setScale(0.5) 20 | self.clippingNode1:setStencil(stencil) 21 | end 22 | if self.clippingNode2 then 23 | local stencil = gk.create_sprite("stencil.png") 24 | local size = self.clippingNode2:getContentSize() 25 | stencil:setPosition(cc.p(size.width / 2, size.height / 2)) 26 | stencil:setScale(0.5) 27 | self.clippingNode2:setStencil(stencil) 28 | end 29 | gk.util:drawNodeBounds(self.clippingNode1, nil, -3) 30 | gk.util:drawNodeBounds(self.node2, nil, -3) 31 | gk.util:drawNodeBounds(self.clippingRectNode1, nil, -3) 32 | gk.util:drawNodeBounds(self.clippingRectNode2, nil, -3) 33 | end 34 | 35 | return ClippingNodeTest 36 | -------------------------------------------------------------------------------- /src/gk/test/gen/value/strings.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 17/1/19 5 | -- Time: 上午9:24 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | return { 10 | confirm = "Confirm", 11 | cancel = "Cancel", 12 | multi_language = "Different language use different font(English: Klee.fnt, Chinese: Arial)", 13 | zoom_button = "ZoomButton", 14 | zoom_button_desc = "ZoomButton's size is decided by its first child, it can be any kind of node.(after change child's size need refresh by Click F1, auto\ 15 | refresh hasn't been implemented)", 16 | sprite_button = "SpriteButton", 17 | sprite_button_desc = "SpriteButton use 3 images indicate 3 different state:\"Normal\", \"Selected\" and \"Disabled\"; there's two kinds of display mode,\"SwithMode\": switch pic between states; \"OverlapMode\": overlap on Normal image;", 18 | toggle_button = "ToggleButton", 19 | toggle_button_desc = "ToggleButton use tag to control which children are currently visible.", 20 | check_box = "CheckBox", 21 | check_box_desc = "", 22 | some_text = "When a country Taxes our products coming in at, say, 50%, and we Tax the same product coming into our country at ZERO, not fair or smart. We\ 23 | will soon be starting RECIPROCAL TAXES so that we will charge the same thing as they charge us. $800 Billion Trade Deficit-have no choice!", 24 | } -------------------------------------------------------------------------------- /src/gk/test/widget/TextButton.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 13/03/2018 5 | -- Time: 14:24 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local TextButton = class("TextButton", gk.Widget) 10 | 11 | function TextButton:ctor() 12 | self:registerCustomProp("labelString", "string") 13 | self:registerCustomProp("onClicked", "function") 14 | TextButton.super.ctor(self) 15 | end 16 | 17 | function TextButton:setLabelString(key) 18 | if self.label1 then 19 | if key:len() > 0 and key:sub(1, 1) == "@" then 20 | key = gk.resource:getString(key:sub(2, #key)) 21 | end 22 | self.label1:setString(key) 23 | end 24 | end 25 | 26 | function TextButton:setOnClicked(onClicked) 27 | local func, macro = gk.generator:parseCustomMacroFunc(self, onClicked) 28 | if func then 29 | self.button1:onClicked(function() 30 | func(self.__rootTable, self) 31 | end) 32 | end 33 | end 34 | 35 | function TextButton:onEnter() 36 | -- auto set position 37 | local size = self:getContentSize() 38 | self.scale9Sprite1:setContentSize(size) 39 | self.button1:setContentNode(self.scale9Sprite1) 40 | self.button1:setPosition(cc.p(size.width / 2, size.height / 2)) 41 | self.label1:setPosition(cc.p(size.width / 2, size.height / 2)) 42 | end 43 | 44 | return TextButton -------------------------------------------------------------------------------- /src/gk/gen/layout/gk_layout_fsmtransnode.lua: -------------------------------------------------------------------------------- 1 | return { 2 | FSMTransNode_from = "nil", 3 | _fold = false, 4 | _id = "fSMTransNode1", 5 | _lock = 1, 6 | height = 0, 7 | width = 0, 8 | x = 640, 9 | y = 360, 10 | _children = { { 11 | _id = "quadBezierNode1", 12 | _type = "QuadBezierNode", 13 | _children = { { 14 | _id = "drawPolygon1", 15 | _lock = 0, 16 | _type = "DrawPolygon", 17 | borderWidth = 0, 18 | lineWidth = 1, 19 | pointsNum = 3, 20 | fillColor = { 21 | a = 1, 22 | b = 0, 23 | g = 1, 24 | r = 0}, 25 | points = { { 26 | x = 0, 27 | y = 0}, 28 | { 29 | x = 11, 30 | y = 5}, 31 | { 32 | x = 11, 33 | y = -5}, 34 | { 35 | x = 150, 36 | y = 50}}}, 37 | { 38 | _id = "button1", 39 | _type = "ZoomButton", 40 | _children = { { 41 | _id = "nameLabel", 42 | _lock = 0, 43 | _type = "cc.Label", 44 | fontSize = 28, 45 | scaleX = 0.5, 46 | scaleY = 0.5, 47 | string = "label"}}}}}}} -------------------------------------------------------------------------------- /src/gk/tools/ErrorReporter.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 18/12/2017 5 | -- Time: 18:56 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ErrorReporter = {} 10 | 11 | local lastReportTime 12 | function ErrorReporter:reportException(detail) 13 | if true then 14 | local now = os.time() 15 | if lastReportTime == nil or now - lastReportTime > 1 then 16 | lastReportTime = now 17 | gk.log("------------------------------[ErrorReporter]------------------------------\n\nErrorReporter:\n%s\n\n------------------------------[ErrorReporter]------------------------------", detail) 18 | gk.errorOccurs = true 19 | if DEBUG ~= 0 then 20 | gk.scheduler:performWithDelayGlobal(function() 21 | local Dialog, _ = gk.resource:require("gk.layout.ErrorReportDialog") 22 | local dialog = Dialog:create() 23 | dialog:setContent(detail) 24 | dialog.closeBtn:onClicked(function() 25 | gk.util:restartGame() 26 | end) 27 | dialog:setPosition(cc.p(gk.display.leftWidth + gk.display.extWidth / 2, gk.display.bottomHeight)) 28 | cc.Director:getInstance():getRunningScene():addChild(dialog, 999999999) 29 | end, 0.2) 30 | end 31 | end 32 | end 33 | end 34 | 35 | return ErrorReporter -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "init_cfg":{ 3 | "isLandscape": true, 4 | "isWindowTop": false, 5 | "name": "gkeditor", 6 | "width": 960, 7 | "height": 640, 8 | "entry": "src/main.lua", 9 | "consolePort": 6050, 10 | "uploadPort": 6060 11 | }, 12 | "simulator_screen_size": [ 13 | { 14 | "title": "iPhone 3Gs (480x320)", 15 | "width": 480, 16 | "height": 320 17 | }, 18 | { 19 | "title": "iPhone 4 (960x640)", 20 | "width": 960, 21 | "height": 640 22 | }, 23 | { 24 | "title": "iPhone 5 (1136x640)", 25 | "width": 1136, 26 | "height": 640 27 | }, 28 | { 29 | "title": "iPad (1024x768)", 30 | "width": 1024, 31 | "height": 768 32 | }, 33 | { 34 | "title": "iPad Retina (2048x1536)", 35 | "width": 2048, 36 | "height": 1536 37 | }, 38 | { 39 | "title": "Android (800x480)", 40 | "width": 800, 41 | "height": 480 42 | }, 43 | { 44 | "title": "Android (854x480)", 45 | "width": 854, 46 | "height": 480 47 | }, 48 | { 49 | "title": "Android (1280x720)", 50 | "width": 1280, 51 | "height": 720 52 | }, 53 | { 54 | "title": "Android (1920x1080)", 55 | "width": 1920, 56 | "height": 1080 57 | } 58 | ] 59 | } 60 | -------------------------------------------------------------------------------- /src/demoapp/MainLayer.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/20 5 | -- Time: 上午9:43 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local MainLayer = class("MainLayer", gk.Layer) 10 | 11 | function MainLayer:ctor() 12 | MainLayer.super.ctor(self) 13 | -- calculate height 14 | local height = (gk.display:designSize().height * gk.display:yScale() - 112 * 2 * gk.display:minScale()) / gk.display:xScale() 15 | self.tableView1:setViewSize(cc.size(self.tableView1:getViewSize().width, height)) 16 | self:setDataSource() 17 | end 18 | 19 | function MainLayer:cellNumsOfTableView() 20 | return #self:getDataSource() 21 | end 22 | 23 | function MainLayer:cellSizeForTable(table, idx) 24 | if not self.cellSize then 25 | -- get cell size 26 | local cell = gk.injector:inflateNode("demoapp.ChatCell") 27 | self.cellSize = cell:getContentSize() 28 | end 29 | return self.cellSize.width, self.cellSize.height 30 | end 31 | 32 | function MainLayer:cellAtIndex(table, idx) 33 | local cell = table:dequeueCell() 34 | 35 | if nil == cell then 36 | cell = gk.injector:inflateNode("demoapp.ChatCell") 37 | end 38 | cell:setScale(1) 39 | cell.nickName:setString(tostring(idx)) 40 | return cell 41 | end 42 | 43 | function MainLayer:getDataSource() 44 | return self.data or {} 45 | end 46 | 47 | function MainLayer:setDataSource() 48 | self.data = { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} } 49 | self.tableView1:reloadData() 50 | end 51 | 52 | return MainLayer -------------------------------------------------------------------------------- /src/gk/core/List.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/4/11 5 | -- Time: 下午2:09 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local List = class("List") 10 | 11 | function List:ctor() 12 | self.first = 0 13 | self.last = -1 14 | end 15 | 16 | function List:pushLeft(value) 17 | local first = self.first - 1 18 | self.first = first 19 | self[first] = value 20 | end 21 | 22 | function List:pushRight(value) 23 | local last = self.last + 1 24 | self.last = last 25 | self[last] = value 26 | end 27 | 28 | function List:popLeft() 29 | local first = self.first 30 | if first > self.last then error("list is empty") end 31 | local value = self[first] 32 | self[first] = nil -- to allow garbage collection 33 | self.first = first + 1 34 | return value 35 | end 36 | 37 | function List:popRight() 38 | local last = self.last 39 | if self.first > last then error("list is empty") end 40 | local value = self[last] 41 | self[last] = nil -- to allow garbage collection 42 | self.last = last - 1 43 | return value 44 | end 45 | 46 | function List:left() 47 | local first = self.first 48 | if first > self.last then error("list is empty") end 49 | local value = self[first] 50 | return value 51 | end 52 | 53 | function List:right() 54 | local last = self.last 55 | if self.first > last then error("list is empty") end 56 | local value = self[last] 57 | return value 58 | end 59 | 60 | function List:size() 61 | return self.last - self.first + 1 62 | end 63 | 64 | gk.List = List -------------------------------------------------------------------------------- /src/gk/node/DrawPolygon.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 31/08/2017 5 | -- Time: 18:02 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNode = import(".DrawNode") 10 | local drawPolygon = class("drawPolygon", DrawNode) 11 | 12 | function drawPolygon:ctor() 13 | drawPolygon.super.ctor(self) 14 | self:addProperty("points", { cc.p(0, 0), cc.p(100, 0), cc.p(100, 50), cc.p(0, 50) }) 15 | self:addProperty("borderWidth", 1) 16 | self:addProperty("fillColor", cc.c4f(0, 0, 0.5, 0)) 17 | self.pointsNum = 4 18 | end 19 | 20 | function drawPolygon:getPointsNum() 21 | return self.pointsNum 22 | end 23 | 24 | function drawPolygon:setPointsNum(pointsNum) 25 | self.pointsNum = pointsNum 26 | while #self.points < self.pointsNum do 27 | table.insert(self.points, cc.pAdd(self.points[#self.points], cc.p(10, 10))) 28 | end 29 | self:draw() 30 | end 31 | 32 | function drawPolygon:draw() 33 | drawPolygon.super.draw(self) 34 | self.child:drawPolygon(self.points, self.pointsNum, self.fillColor, self.borderWidth, self.c4f) 35 | end 36 | 37 | function drawPolygon:getMovablePoints() 38 | local ps = {} 39 | for i, p in ipairs(self.points) do 40 | if i > self.pointsNum then 41 | return {} 42 | end 43 | table.insert(ps, p) 44 | end 45 | return ps 46 | end 47 | 48 | function drawPolygon:setMovablePoints(p, index) 49 | for i, dst in ipairs(self.points) do 50 | if i > self.pointsNum then 51 | return 52 | end 53 | if i == index then 54 | self.points[i] = p 55 | break 56 | end 57 | end 58 | self:draw() 59 | end 60 | 61 | return drawPolygon -------------------------------------------------------------------------------- /src/gk/tools/scheduler.lua: -------------------------------------------------------------------------------- 1 | local scheduler = {} 2 | local director = cc.Director:getInstance() 3 | local sharedScheduler = director:getScheduler() 4 | 5 | function scheduler:scheduleScriptFunc(listener, interval, pause) 6 | local handle = sharedScheduler:scheduleScriptFunc(listener, interval, pause) 7 | self:_getScheduleIds()[handle] = true 8 | return handle 9 | end 10 | 11 | function scheduler:scheduleUpdateGlobal(listener) 12 | local handle = sharedScheduler:scheduleScriptFunc(listener, 0, false) 13 | self:_getScheduleIds()[handle] = true 14 | return handle 15 | end 16 | 17 | function scheduler:scheduleGlobal(listener, interval) 18 | local handle = sharedScheduler:scheduleScriptFunc(listener, 0, false) 19 | self:_getScheduleIds()[handle] = true 20 | return handle 21 | end 22 | 23 | function scheduler:unscheduleGlobal(handle) 24 | sharedScheduler:unscheduleScriptEntry(handle) 25 | self:_getScheduleIds()[handle] = nil 26 | end 27 | 28 | function scheduler:unscheduleScriptEntry(handle) 29 | sharedScheduler:unscheduleScriptEntry(handle) 30 | self:_getScheduleIds()[handle] = nil 31 | end 32 | 33 | function scheduler:performWithDelayGlobal(listener, time) 34 | local handle 35 | handle = sharedScheduler:scheduleScriptFunc(function() 36 | self:unscheduleGlobal(handle) 37 | listener() 38 | end, time, false) 39 | self:_getScheduleIds()[handle] = true 40 | return handle 41 | end 42 | 43 | function scheduler:_getScheduleIds() 44 | self.scheduleIds = self.scheduleIds or {} 45 | return self.scheduleIds 46 | end 47 | 48 | function scheduler:unscheduleAll() 49 | for scheduleId, _ in pairs(self:_getScheduleIds()) do 50 | sharedScheduler:unscheduleScriptEntry(scheduleId) 51 | end 52 | self.scheduleIds = {} 53 | end 54 | 55 | return scheduler 56 | 57 | -------------------------------------------------------------------------------- /src/gk/layout/FSMTransNode.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 19/12/2017 5 | -- Time: 18:47 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | local FSMTransNode = class("FSMTransNode", gk.Widget) 9 | 10 | function FSMTransNode:ctor(...) 11 | self:registerCustomProp("action", "string") 12 | self:registerCustomProp("from", "string") 13 | self:registerCustomProp("to", "string") 14 | FSMTransNode.super.ctor(self, ...) 15 | 16 | self.quadBezierNode1.onDrawCallback = function() 17 | local origin = self.quadBezierNode1.origin 18 | local c1 = self.quadBezierNode1.destination[1].c1 19 | local destination = self.quadBezierNode1.destination[1].dst 20 | local angle = -180 * cc.pToAngleSelf(cc.pSub(c1, destination)) / math.pi 21 | self.drawPolygon1:setPosition(destination) 22 | self.drawPolygon1:setRotation(angle) 23 | local p = {} 24 | local t = 0.5 25 | p.x = math.pow(1 - t, 2) * origin.x + 2.0 * (1 - t) * t * c1.x + t * t * destination.x 26 | p.y = math.pow(1 - t, 2) * origin.y + 2.0 * (1 - t) * t * c1.y + t * t * destination.y 27 | self.button1:setPosition(p) 28 | end 29 | end 30 | 31 | function FSMTransNode:setAction(action) 32 | self.action = action 33 | if self.nameLabel then 34 | self.nameLabel:setString(action) 35 | self.button1:setContentNode(self.nameLabel) 36 | end 37 | end 38 | 39 | function FSMTransNode:setTransabled(transable) 40 | self.quadBezierNode1:setC4f(transable and cc.c4f(0, 1, 0, 1) or cc.c4f(153 / 255, 153 / 255, 153 / 255, 1)) 41 | self.drawPolygon1:setFillColor(transable and cc.c4f(0, 1, 0, 1) or cc.c4f(153 / 255, 153 / 255, 153 / 255, 1)) 42 | self.quadBezierNode1:draw() 43 | self.drawPolygon1:draw() 44 | end 45 | 46 | return FSMTransNode 47 | -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_c3dlayertest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = false, 3 | _id = "c3DLayerTest1", 4 | _type = "C3DLayerTest", 5 | height = "$fill", 6 | width = "$fill", 7 | _children = { { 8 | _id = "label3", 9 | _type = "cc.Label", 10 | color = "00ff00", 11 | fontSize = 30, 12 | opacity = 100, 13 | scaleX = "$minScale", 14 | scaleY = "$minScale", 15 | string = "label", 16 | x = 640, 17 | y = 360, 18 | scaleXY = { 19 | x = "$scaleX", 20 | y = "$scaleY"}}, 21 | { 22 | _id = "label1", 23 | _type = "cc.Label", 24 | color = "ff0000", 25 | fontSize = 30, 26 | opacity = 100, 27 | scaleX = "$minScale", 28 | scaleY = "$minScale", 29 | string = "label", 30 | x = 640, 31 | y = 360, 32 | scaleXY = { 33 | x = "$scaleX", 34 | y = "$scaleY"}}, 35 | { 36 | _id = "label2", 37 | _type = "cc.Label", 38 | fontSize = 18, 39 | scaleX = "$minScale", 40 | scaleY = "$minScale", 41 | string = "label", 42 | x = 256, 43 | y = 271, 44 | scaleXY = { 45 | x = "$scaleX", 46 | y = "$scaleY"}}, 47 | { 48 | _id = "layer3d", 49 | _type = "cc.Layer", 50 | height = "$fill", 51 | width = "$fill", 52 | _children = { { 53 | _id = "sprite3D1", 54 | _is3d = true, 55 | _type = "cc.Sprite3D", 56 | modelPath = "gk/res/3d/orc.c3b", 57 | scaleX = 3, 58 | scaleY = 3, 59 | x = 277, 60 | y = 205, 61 | blendFunc = { 62 | dst = 771, 63 | src = 770}, 64 | rotation3D = { 65 | x = 0, 66 | y = 0, 67 | z = -0}}}}}} -------------------------------------------------------------------------------- /src/gk/action/BreathAction.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by localelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 7/19/17 5 | -- Time: 10:55 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local BreathAction = class("BreathAction") 10 | 11 | function BreathAction:ctor(actionInterval) 12 | assert(gk.util:instanceof(actionInterval, "cc.ActionInterval"), "must use cc.ActionInterval!") 13 | self.actionInterval = actionInterval 14 | self.duration = self.actionInterval:getDuration() 15 | self._elapsed = 0 16 | end 17 | 18 | function BreathAction:start(target) 19 | self.actionInterval:retain() 20 | self.actionInterval:startWithTarget(target) 21 | self.scheduler = gk.scheduler:scheduleUpdateGlobal(function(delta) 22 | self:step(delta) 23 | if self._elapsed >= self.duration then 24 | self._elapsed = 0 25 | end 26 | end) 27 | end 28 | 29 | function BreathAction:stop() 30 | self.actionInterval:release() 31 | gk.scheduler:unscheduleGlobal(self.scheduler) 32 | end 33 | 34 | function BreathAction:step(delta) 35 | self._elapsed = self._elapsed + delta 36 | local updateDt = math.max(0, math.min(1, self._elapsed / self.duration)) 37 | self:update(updateDt) 38 | end 39 | 40 | function BreathAction:update(time) 41 | self.actionInterval:update(self:getInterpolation(time)) 42 | end 43 | 44 | function BreathAction:getInterpolation(input) 45 | local x = 6 * input 46 | local k = 1.0 / 3 47 | local t = 6 48 | local n = 1 49 | local PI = 3.1416 50 | local output = 0 51 | 52 | if (x >= ((n - 1) * t) and x < ((n - (1 - k)) * t)) then 53 | output = (0.5 * math.sin((PI / (k * t)) * ((x - k * t / 2) - (n - 1) * t)) + 0.5) 54 | elseif (x >= (n - (1 - k)) * t and x < n * t) then 55 | output = math.pow((0.5 * math.sin((PI / ((1 - k) * t)) * ((x - (3 - k) * t / 2) - (n - 1) * t)) + 0.5), 2) 56 | end 57 | return output 58 | end 59 | 60 | return BreathAction -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_dialog_dialog1.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = true, 3 | _id = "dialog11", 4 | _type = "Dialog1", 5 | height = "$fill", 6 | width = "$fill", 7 | _children = { { 8 | _fold = false, 9 | _id = "popupBg1", 10 | _isWidget = 0, 11 | _lock = 0, 12 | _type = "gk/test/widget/PopupBg", 13 | height = 350, 14 | ignoreAnchor = 1, 15 | scaleX = "$minScale", 16 | scaleY = "$minScale", 17 | width = 600, 18 | x = 640, 19 | y = 360, 20 | anchor = { 21 | x = 0.5, 22 | y = 0.5}, 23 | scaleXY = { 24 | x = "$scaleX", 25 | y = "$scaleY"}, 26 | _children = { { 27 | TextButton_labelString = "@cancel", 28 | TextButton_onClicked = "&onCancelClicked", 29 | _fold = false, 30 | _id = "textButton1", 31 | _isWidget = 0, 32 | _lock = 0, 33 | _type = "gk/test/widget/TextButton", 34 | height = 55, 35 | scaleX = 1, 36 | scaleY = 1, 37 | width = 180, 38 | x = 280, 39 | y = 70, 40 | anchor = { 41 | x = 1, 42 | y = 0.5}, 43 | scaleXY = { 44 | x = "1", 45 | y = "1"}}, 46 | { 47 | TextButton_labelString = "@confirm", 48 | TextButton_onClicked = "&onConfirmClicked", 49 | _fold = true, 50 | _id = "textButton2", 51 | _isWidget = 0, 52 | _lock = 0, 53 | _type = "gk/test/widget/TextButton", 54 | height = 55, 55 | scaleX = 1, 56 | scaleY = 1, 57 | width = 180, 58 | x = 320, 59 | y = 70, 60 | anchor = { 61 | x = 0, 62 | y = 0.5}, 63 | scaleXY = { 64 | x = "1", 65 | y = "1"}}}}}} -------------------------------------------------------------------------------- /src/gk/test/SolarSystem.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 15/08/2017 5 | -- Time: 22:34 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local SolarSystem = class("SolarSystem", gk.Layer) 10 | 11 | function SolarSystem:ctor() 12 | SolarSystem.super.ctor(self) 13 | 14 | local durations = { 0.24, 0.62, 1, 1.88, 11.86, 29.46, 1 / 30 } 15 | self:move(self.mercury, self.circle_mercury:getContentSize().width / 2, durations[1]) 16 | self:move(self.venus, self.circle_venus:getContentSize().width / 2, durations[2]) 17 | self:move(self.earth, self.circle_earth:getContentSize().width / 2, durations[3]) 18 | self:move(self.mars, self.circle_mars:getContentSize().width / 2, durations[4]) 19 | self:move(self.jupiter, self.circle_jupiter:getContentSize().width / 2, durations[5]) 20 | self:move(self.saturn, self.circle_saturn:getContentSize().width / 2, durations[6]) 21 | self:move(self.moon, self.circle_moon:getContentSize().width / 2, durations[7]) 22 | end 23 | 24 | function SolarSystem:move(node, radius, dur) 25 | local magic = 0.552284749831 26 | local time = 8 27 | local delta = time * dur / 4 28 | node:setPosition(cc.p(radius, 0)) 29 | self:runAction(cc.Sequence:create(cc.DelayTime:create(math.random(2, 20) / 10), cc.CallFunc:create(function() 30 | node:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.BezierTo:create(delta, { 31 | cc.p(radius * (1 + magic), 0), cc.p(radius * 2, radius * (1 - magic)), cc.p(radius * 2, radius) 32 | }), cc.BezierTo:create(delta, { 33 | cc.p(radius * 2, radius * (1 + magic)), cc.p(radius * (1 + magic), radius * 2), cc.p(radius, radius * 2) 34 | }), cc.BezierTo:create(delta, { 35 | cc.p(radius * (1 - magic), radius * 2), cc.p(0, radius * (1 + magic)), cc.p(0, radius) 36 | }), cc.BezierTo:create(delta, { 37 | cc.p(0, radius * (1 - magic)), cc.p(radius * (1 - magic), 0), cc.p(radius, 0) 38 | })))) 39 | end))) 40 | end 41 | 42 | return SolarSystem -------------------------------------------------------------------------------- /src/gk/node/DrawNode.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 31/08/2017 5 | -- Time: 16:07 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNode = class("DrawNode", function() 10 | return cc.Node:create() 11 | end) 12 | 13 | function DrawNode:ctor() 14 | self:enableNodeEvents() 15 | self:setAnchorPoint(cc.p(0.5, 0.5)) 16 | self.child = cc.DrawNode:create() 17 | self:addChild(self.child) 18 | self:addProperty("c4f", cc.c4f(0, 1, 0, 1)) 19 | self:addProperty("lineWidth", 1) 20 | end 21 | 22 | function DrawNode:onEnter() 23 | self:draw() 24 | end 25 | 26 | function DrawNode:addProperty(propName, defaultValue) 27 | self[propName] = defaultValue 28 | local getter = "get" .. string.upper(propName:sub(1, 1)) .. propName:sub(2, propName:len()) 29 | local setter = "set" .. string.upper(propName:sub(1, 1)) .. propName:sub(2, propName:len()) 30 | self[getter] = function(_) 31 | return self[propName] 32 | end 33 | self[setter] = function(_, var) 34 | if self[propName] ~= var then 35 | self[propName] = var 36 | self:draw() 37 | end 38 | end 39 | end 40 | 41 | function DrawNode:addBoolProperty(propName, defaultValue) 42 | self[propName] = defaultValue 43 | local getter = "is" .. string.upper(propName:sub(1, 1)) .. propName:sub(2, propName:len()) 44 | local setter = "set" .. string.upper(propName:sub(1, 1)) .. propName:sub(2, propName:len()) 45 | self[getter] = function(_) 46 | return self[propName] 47 | end 48 | self[setter] = function(_, var) 49 | if self[propName] ~= var then 50 | self[propName] = var 51 | self:draw() 52 | end 53 | end 54 | end 55 | 56 | function DrawNode:draw() 57 | -- Override to custom draw 58 | self.child:clear() 59 | self.child:setLineWidth(self.lineWidth) 60 | end 61 | 62 | function DrawNode:afterDraw() 63 | if self.onDrawCallback then 64 | self.onDrawCallback() 65 | end 66 | end 67 | 68 | return DrawNode -------------------------------------------------------------------------------- /src/demoapp/gen/layout/demoapp_chatcell.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _id = "ChatCell", 3 | _type = "ChatCell", 4 | height = 120, 5 | scaleX = "$xScale", 6 | scaleY = "$xScale", 7 | width = 720, 8 | anchor = { 9 | x = 0, 10 | y = 0}, 11 | _children = { { 12 | _id = "layerColor1", 13 | _type = "cc.LayerColor", 14 | height = "$fill", 15 | width = "$fill", 16 | _children = { { 17 | _id = "bottomLine", 18 | _type = "cc.LayerColor", 19 | color = "f0f0f0ff", 20 | height = 1, 21 | width = "$fill"}, 22 | { 23 | _id = "avatar", 24 | _type = "cc.Sprite", 25 | file = "main/avatar.png", 26 | x = 61, 27 | y = 60}, 28 | { 29 | _id = "nickName", 30 | _type = "cc.Label", 31 | color = "000000", 32 | fontSize = 32, 33 | height = 0, 34 | string = "NickName", 35 | width = 0, 36 | x = 120, 37 | y = 74, 38 | anchor = { 39 | x = 0, 40 | y = 0.5}}, 41 | { 42 | _id = "desc", 43 | _type = "cc.Label", 44 | color = "a6a6a6", 45 | enableWrap = true, 46 | fontSize = 20, 47 | height = 0, 48 | overflow = 2, 49 | string = "[Message]", 50 | width = 500, 51 | x = 120, 52 | y = 40, 53 | anchor = { 54 | x = 0, 55 | y = 0.5}}, 56 | { 57 | _id = "time", 58 | _type = "cc.Label", 59 | color = "a6a6a6", 60 | fontSize = 20, 61 | height = 0, 62 | string = "13:57", 63 | width = 0, 64 | x = 686, 65 | y = 80, 66 | anchor = { 67 | x = 1, 68 | y = 0.5}}, 69 | { 70 | _id = "dot", 71 | _type = "cc.Sprite", 72 | color = "ff0000", 73 | file = "main/dot.png", 74 | x = 95, 75 | y = 93}}}}} -------------------------------------------------------------------------------- /src/gk/instanceRun.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/30/17 5 | -- Time: 16:14 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | -- instance run on Mac or Android platform 10 | local instanceRun = {} 11 | 12 | -- must init this in main.lua before require any other modules 13 | function instanceRun:init(androidPackageName) 14 | androidPackageName = androidPackageName or "" 15 | local MAC_ROOT = "" 16 | local ANDROID_PACKAGE_NAME = androidPackageName 17 | local ANDROID_ROOT = "/sdcard/" .. androidPackageName .. "/" 18 | 19 | local platform = cc.Application:getInstance():getTargetPlatform() 20 | -- mac use local search path for restart instantly 21 | if platform == 2 then 22 | local path = cc.FileUtils:getInstance():fullPathForFilename("src/main.lua") 23 | MAC_ROOT = string.sub(path, 1, string.find(path, "runtime/mac") - 1) 24 | print(string.format("initInstanceRun on Mac, MAC_ROOT = \"%s\"", MAC_ROOT)) 25 | cc.FileUtils:getInstance():setSearchPaths({}) 26 | cc.FileUtils:getInstance():addSearchPath(MAC_ROOT .. "src/") 27 | cc.FileUtils:getInstance():addSearchPath(MAC_ROOT .. "res/") 28 | cc.FileUtils:getInstance():addSearchPath(MAC_ROOT) 29 | elseif platform == 3 and androidPackageName ~= "" then 30 | print(string.format("Android package name = \"%s\"", ANDROID_PACKAGE_NAME)) 31 | print(string.format("initInstanceRun on Android, ANDROID_ROOT = \"%s\"", ANDROID_ROOT)) 32 | if not cc.FileUtils:getInstance():isDirectoryExist(ANDROID_PACKAGE_NAME) then 33 | cc.FileUtils:getInstance():createDirectory(ANDROID_PACKAGE_NAME) 34 | end 35 | cc.FileUtils:getInstance():setSearchPaths({}) 36 | cc.FileUtils:getInstance():addSearchPath(ANDROID_ROOT .. "src/") 37 | cc.FileUtils:getInstance():addSearchPath(ANDROID_ROOT .. "res/") 38 | cc.FileUtils:getInstance():addSearchPath(ANDROID_ROOT) 39 | cc.FileUtils:getInstance():addSearchPath("src/") 40 | cc.FileUtils:getInstance():addSearchPath("res/") 41 | end 42 | 43 | self.MAC_ROOT = MAC_ROOT 44 | self.ANDROID_ROOT = ANDROID_ROOT 45 | self.ANDROID_PACKAGE_NAME = ANDROID_PACKAGE_NAME 46 | end 47 | 48 | return instanceRun -------------------------------------------------------------------------------- /src/gk/script/push.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | project_root=os.sys.argv[1] 5 | adb=os.sys.argv[2] 6 | packageName=os.sys.argv[3] 7 | defaultActivity=os.sys.argv[4] 8 | android_dir=os.sys.argv[5] 9 | 10 | print "mac project_root = " + project_root 11 | print "adb path = " + adb 12 | print "packageName = " + packageName 13 | print "defaultActivity = " + defaultActivity 14 | print "android_dir = " + android_dir 15 | 16 | os.chdir(project_root) 17 | 18 | os.system("mkdir -p " + project_root + "/gen") 19 | filePath = project_root + "/gen/filelist.txt" 20 | filePath_tmp = project_root + "/gen/filelist_tmp.txt" 21 | 22 | files={} 23 | changedFiles={} 24 | if os.path.exists(filePath): 25 | fin = open(filePath, 'r') 26 | lines = fin.readlines() 27 | fin.close() 28 | for line in lines: 29 | pos=line.find(' ') 30 | k=line[:pos] 31 | v=line[pos+1:] 32 | files[k]=v 33 | 34 | whiteList = ["png", "jpg", "jpeg", "plist", "tmx", "tsx", "ttf", "fnt", "fsh", "vsh", "json", "mp3"] 35 | append = "" 36 | for k in whiteList: 37 | append = append + "|" + k 38 | 39 | os.system("rm -f " + filePath_tmp) 40 | os.system("find -E src -regex '.*\.(lua"+ append + ")' -exec md5 {} \;|awk '{print $2,$4}'|awk -F[\(\)] '{print $2$3}' >> " + filePath_tmp) 41 | os.system("find -E res -regex '.*\.(lua"+ append + ")' -exec md5 {} \;|awk '{print $2,$4}'|awk -F[\(\)] '{print $2$3}' >> " + filePath_tmp) 42 | 43 | fin = open(filePath_tmp, 'r') 44 | lines = fin.readlines() 45 | fin.close() 46 | print("total files count = " + str(len(lines))) 47 | for line in lines: 48 | pos=line.find(' ') 49 | k=line[:pos] 50 | v=line[pos+1:] 51 | if (not (k in files) or files[k] != v): 52 | changedFiles[k]=v 53 | 54 | os.system("mv " + filePath_tmp + " " + filePath) 55 | 56 | os.system("find res -type d -exec " + adb + " shell mkdir -p " + android_dir + "/{} \;") 57 | os.system("find src -type d -exec " + adb + " shell mkdir -p " + android_dir + "/{} \;") 58 | 59 | for key, value in changedFiles.iteritems() : 60 | # print key 61 | os.system(adb + " push " + key + " " + android_dir + key) 62 | 63 | print("changed files count = " + str(len(changedFiles))) 64 | os.system(adb + " shell am force-stop " + packageName) 65 | os.system(adb + " shell am start -n " + packageName + "/" + defaultActivity) 66 | -------------------------------------------------------------------------------- /src/gk/node/QuadBezierNode.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 20/12/2017 5 | -- Time: 11:02 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNode = import(".DrawNode") 10 | local QuadBezierNode = class("QuadBezierNode", DrawNode) 11 | 12 | function QuadBezierNode:ctor() 13 | QuadBezierNode.super.ctor(self) 14 | self:addProperty("origin", cc.p(0, 0)) 15 | self:addProperty("destination", { { c1 = cc.p(50, 50), dst = cc.p(100, 0) } }) 16 | self:addProperty("segments", 50) 17 | self.curvesNum = 1 18 | end 19 | 20 | function QuadBezierNode:getCurvesNum() 21 | return self.curvesNum 22 | end 23 | 24 | function QuadBezierNode:setCurvesNum(curvesNum) 25 | self.curvesNum = curvesNum 26 | while #self.destination < self.curvesNum do 27 | local count = #self.destination 28 | table.insert(self.destination, { c1 = cc.p(50 + count * 100, 50), dst = cc.p((count + 1) * 100, 0) }) 29 | end 30 | self:draw() 31 | end 32 | 33 | function QuadBezierNode:draw() 34 | QuadBezierNode.super.draw(self) 35 | local origin = cc.p(self.origin) 36 | for i, dst in ipairs(self.destination) do 37 | if i > self.curvesNum then 38 | return 39 | end 40 | self.child:drawQuadBezier(origin, dst.c1, dst.dst, self.segments, self.c4f) 41 | origin = dst.dst 42 | end 43 | self:afterDraw() 44 | end 45 | 46 | function QuadBezierNode:getMovablePoints() 47 | local ps = {} 48 | table.insert(ps, self.origin) 49 | for i, dst in ipairs(self.destination) do 50 | if i > self.curvesNum then 51 | return {} 52 | end 53 | table.insert(ps, dst.c1) 54 | table.insert(ps, dst.dst) 55 | end 56 | return ps 57 | end 58 | 59 | function QuadBezierNode:setMovablePoints(p, index) 60 | local idx = 1 61 | if idx == index then 62 | self.origin = cc.p(p) 63 | else 64 | for i, dst in ipairs(self.destination) do 65 | idx = idx + 1 66 | if idx == index then 67 | self.destination[i].c1 = p 68 | break 69 | end 70 | idx = idx + 1 71 | if idx == index then 72 | self.destination[i].dst = p 73 | break 74 | end 75 | end 76 | end 77 | self:draw() 78 | end 79 | 80 | return QuadBezierNode -------------------------------------------------------------------------------- /src/gk/test/Path.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 2019/1/23 5 | -- Time: 15:41 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | -- 10 | -- Created by IntelliJ IDEA. 11 | -- User: Kunkka 12 | -- Date: 17/3/1 13 | -- Time: 下午9:26 14 | -- To change this template use File | Settings | File Templates. 15 | -- 16 | 17 | local Path = class("Path", gk.Layer) 18 | 19 | function Path:ctor() 20 | Path.super.ctor(self) 21 | 22 | 23 | self:run() 24 | end 25 | 26 | function Path:run() 27 | self.sprite1:setPosition(cc.p(0, 0)) 28 | local x0 = 0 29 | local y0 = 0 30 | local x3 = math.random(-720, 720) 31 | local y3 = math.random(-720, 720) 32 | local x1, y1, x2, y2 33 | if (x3 > x0 and y3 >= y0) then 34 | -- q1 35 | x1 = x0 + (x3 - x0) / 3 36 | x2 = x0 + (x3 - x0) / 3 * 2 37 | y1 = math.max(-(x3 - x0), y3 + 80) 38 | y2 = (y1 + y3) / 2 39 | elseif (x3 < x0 and y3 >= y0) then 40 | -- q2 41 | x1 = x0 + (x3 - x0) / 3 42 | x2 = x0 + (x3 - x0) / 3 * 2 43 | y1 = math.max(-(x3 - x0), y3 + 80) 44 | y2 = (y1 + y3) / 2 45 | elseif (x3 < x0 and y3 <= y0) then 46 | -- q3 47 | x1 = x0 + (x3 - x0) / 3 48 | x2 = x0 + (x3 - x0) / 3 * 2 49 | y1 = y0 + 100 50 | y2 = (y1 + y3) / 2 51 | elseif (x3 > x0 and y3 <= y0) then 52 | -- q4 53 | x1 = x0 + (x3 - x0) / 3 54 | x2 = x0 + (x3 - x0) / 3 * 2 55 | y1 = y0 + 100 56 | y2 = (y1 + y0) / 2 57 | elseif (x0 == x3) then 58 | if (y3 > y0) then 59 | -- vertical up 60 | x1 = x0 - 100 61 | x2 = x0 - 50 62 | y1 = y3 + 100 63 | y2 = y3 + 50 64 | else 65 | -- vertical down 66 | x1 = x0 - 100 67 | x2 = x0 - 50 68 | y1 = y0 + 100 69 | y2 = y0 + (y3 - y0) / 2 70 | end 71 | end 72 | self.cubicBezierNode:setMovablePoints(cc.p(x1, y1), 2) 73 | self.cubicBezierNode:setMovablePoints(cc.p(x2, y2), 3) 74 | self.cubicBezierNode:setMovablePoints(cc.p(x3, y3), 4) 75 | gk.util:drawNode(self.cubicBezierNode) 76 | gk.log("(%d,%d) (%d,%d)(%d,%d) (%d,%d)", x0, y0, x1, y1, x2, y2, x3, y3) 77 | self.sprite1:runAction(cc.Sequence:create(cc.BezierTo:create(0.8, { cc.p(x1, y1), cc.p(x2, y2), cc.p(x3, y3) }), 78 | cc.DelayTime:create(0.3), cc.CallFunc:create(function() 79 | self:run() 80 | end))) 81 | end 82 | 83 | return Path -------------------------------------------------------------------------------- /src/gk/test/api/APITest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 5/19/17 5 | -- Time: 14:57 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local APITest = class("APITest", gk.Layer) 10 | 11 | function APITest:ctor() 12 | APITest.super.ctor(self) 13 | 14 | gk.log("cc.iskindof test: \"Dialog\" <== \"Layer\" <== \"cc.Layer\" <== \"cc.Node\"") 15 | local Dialog = gk.Dialog 16 | local dialog = gk.Dialog.new() 17 | local Layer = gk.Layer 18 | local layer = gk.Layer.new() 19 | local class_iskindof = function(class, type) 20 | gk.log("Class:Dialog iskindof %s = %s", type, iskindof(class, type)) 21 | end 22 | local instanceof = function(obj, type) 23 | gk.log("Instance:dialog iskindof %s = %s", type, iskindof(obj, type)) 24 | end 25 | class_iskindof(Dialog, "Dialog") 26 | class_iskindof(Dialog, "Layer") 27 | class_iskindof(Dialog, "cc.Layer") 28 | class_iskindof(Dialog, "cc.Node") 29 | -- -- cc.iskindof will crash ... 30 | -- instanceof(dialog, "Dialog") 31 | -- instanceof(dialog, "Layer") 32 | -- instanceof(dialog, "cc.Layer") 33 | -- instanceof(dialog, "cc.Node") 34 | 35 | gk.log("gk.util test: \"Dialog\" <== \"Layer\" <== \"cc.Layer\" <== \"cc.Node\"") 36 | local class_iskindof = function(class, type) 37 | gk.log("Class:Dialog gk.util:iskindof %s = %s", type, gk.util:iskindof(class, type)) 38 | end 39 | local instanceof = function(obj, type) 40 | gk.log("Instance:dialog gk.util:instanceof %s = %s", type, gk.util:instanceof(obj, type)) 41 | end 42 | class_iskindof(Dialog, "Dialog") 43 | class_iskindof(Dialog, "Layer") 44 | class_iskindof(Dialog, "cc.Layer") 45 | class_iskindof(Dialog, "cc.Node") 46 | 47 | instanceof(dialog, "Dialog") 48 | instanceof(dialog, "Layer") 49 | instanceof(dialog, "cc.Layer") 50 | instanceof(dialog, "cc.Node") 51 | 52 | local class_iskindof = function(class, type) 53 | gk.log("Class:Layer gk.util:iskindof %s = %s", type, gk.util:iskindof(class, type)) 54 | end 55 | local instanceof = function(obj, type) 56 | gk.log("Instance:layer gk.util:instanceof %s = %s", type, gk.util:instanceof(obj, type)) 57 | end 58 | class_iskindof(Layer, "Dialog") 59 | class_iskindof(Layer, "Layer") 60 | class_iskindof(Layer, "cc.Layer") 61 | class_iskindof(Layer, "cc.Node") 62 | 63 | instanceof(layer, "Dialog") 64 | instanceof(layer, "Layer") 65 | instanceof(layer, "cc.Layer") 66 | instanceof(layer, "cc.Node") 67 | end 68 | 69 | return APITest -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_particlesystemtest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = true, 3 | _id = "particleSystemTest1", 4 | _type = "ParticleSystemTest", 5 | height = "$fill", 6 | width = "$fill", 7 | _children = { { 8 | _fold = false, 9 | _id = "sprite1", 10 | _type = "cc.Sprite", 11 | scaleX = "$minScale", 12 | scaleY = "$minScale", 13 | x = 185, 14 | y = 150, 15 | scaleXY = { 16 | x = "$scaleX", 17 | y = "$scaleY"}, 18 | _children = { { 19 | _id = "particleSystemQuad1", 20 | _type = "cc.ParticleSystemQuad", 21 | height = 0, 22 | particle = "gk/res/particle/Galaxy.plist", 23 | positionType = 1, 24 | width = 0, 25 | x = 50, 26 | y = 77}}}, 27 | { 28 | _id = "particleSystemQuad2", 29 | _type = "cc.ParticleSystemQuad", 30 | emitterMode = 0, 31 | height = 0, 32 | particle = "gk/res/particle/Galaxy.plist", 33 | positionType = 0, 34 | scaleX = "$minScale", 35 | scaleY = "$minScale", 36 | totalParticles = 934, 37 | width = 0, 38 | x = 640, 39 | y = 150, 40 | blendFunc = { 41 | dst = 1, 42 | src = 770}, 43 | scaleXY = { 44 | x = "$scaleX", 45 | y = "$scaleY"}}, 46 | { 47 | _id = "particleSystemQuad3", 48 | _type = "cc.ParticleSystemQuad", 49 | angle = 90, 50 | angleVar = 360, 51 | autoRemoveOnFinish = 1, 52 | displayFrame = "particle.png", 53 | duration = -1, 54 | emitterMode = 0, 55 | endSize = 37, 56 | height = 0, 57 | life = 4, 58 | lifeVar = 1, 59 | particle = "", 60 | positionType = 0, 61 | radialAccel = -20, 62 | scaleX = "$minScale", 63 | scaleY = "$minScale", 64 | speed = 59, 65 | speedVar = 10, 66 | startSize = 37, 67 | startSizeVar = 10, 68 | startSpin = 0, 69 | tangentialAccel = 50, 70 | tangentialAccelVar = 50, 71 | totalParticles = 500, 72 | width = 0, 73 | x = 1000, 74 | y = 384, 75 | blendFunc = { 76 | dst = 1, 77 | src = 770}, 78 | endColor = { 79 | a = 1, 80 | b = 0, 81 | g = 1, 82 | r = 0}, 83 | gravity = { 84 | x = 150, 85 | y = -300}, 86 | scaleXY = { 87 | x = "$scaleX", 88 | y = "$scaleY"}, 89 | startColor = { 90 | a = 1, 91 | b = 0.76, 92 | g = 0.25, 93 | r = 0}}}} -------------------------------------------------------------------------------- /src/gk/node/CubicBezierNode.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 11/08/2017 5 | -- Time: 15:42 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local DrawNode = import(".DrawNode") 10 | local CubicBezierNode = class("CubicBezierNode", DrawNode) 11 | 12 | function CubicBezierNode:ctor() 13 | CubicBezierNode.super.ctor(self) 14 | self:addProperty("origin", cc.p(0, 0)) 15 | self:addProperty("destination", { { c1 = cc.p(25, 50), c2 = cc.p(75, -50), dst = cc.p(100, 0) } }) 16 | self:addProperty("segments", 50) 17 | self.curvesNum = 1 18 | end 19 | 20 | function CubicBezierNode:getCurvesNum() 21 | return self.curvesNum 22 | end 23 | 24 | function CubicBezierNode:setCurvesNum(curvesNum) 25 | self.curvesNum = curvesNum 26 | while #self.destination < self.curvesNum do 27 | local count = #self.destination 28 | table.insert(self.destination, { c1 = cc.p(25 + count * 100, 50), c2 = cc.p(75 + count * 100, -50), dst = cc.p((count + 1) * 100, 0) }) 29 | end 30 | self:draw() 31 | end 32 | 33 | function CubicBezierNode:draw() 34 | CubicBezierNode.super.draw(self) 35 | local origin = cc.p(self.origin) 36 | for i, dst in ipairs(self.destination) do 37 | if i > self.curvesNum then 38 | return 39 | end 40 | self.child:drawCubicBezier(origin, dst.c1, dst.c2, dst.dst, self.segments, self.c4f) 41 | origin = dst.dst 42 | end 43 | self:afterDraw() 44 | end 45 | 46 | function CubicBezierNode:getMovablePoints() 47 | local ps = {} 48 | table.insert(ps, self.origin) 49 | for i, dst in ipairs(self.destination) do 50 | if i > self.curvesNum then 51 | return {} 52 | end 53 | table.insert(ps, dst.c1) 54 | table.insert(ps, dst.c2) 55 | table.insert(ps, dst.dst) 56 | end 57 | return ps 58 | end 59 | 60 | function CubicBezierNode:setMovablePoints(p, index) 61 | local idx = 1 62 | if idx == index then 63 | self.origin = cc.p(p) 64 | else 65 | for i, dst in ipairs(self.destination) do 66 | idx = idx + 1 67 | if idx == index then 68 | self.destination[i].c1 = p 69 | break 70 | end 71 | idx = idx + 1 72 | if idx == index then 73 | self.destination[i].c2 = p 74 | break 75 | end 76 | idx = idx + 1 77 | if idx == index then 78 | self.destination[i].dst = p 79 | break 80 | end 81 | end 82 | end 83 | self:draw() 84 | end 85 | 86 | return CubicBezierNode -------------------------------------------------------------------------------- /src/gk/gen/layout/gk_layout_errorreportdialog.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = true, 3 | _id = "errorReportDialog1", 4 | enableKeyPad = 1, 5 | height = "$fill", 6 | popOnBack = 1, 7 | touchEnabled = 1, 8 | width = "$fill", 9 | _children = { { 10 | _fold = false, 11 | _id = "dialogBg", 12 | _type = "cc.LayerColor", 13 | color = "f5f5f5ff", 14 | height = 500, 15 | ignoreAnchor = 1, 16 | scaleX = "$minScale", 17 | scaleY = "$minScale", 18 | width = 900, 19 | x = 640, 20 | y = 360, 21 | scaleXY = { 22 | x = "$scaleX", 23 | y = "$scaleY"}, 24 | _children = { { 25 | _id = "layerGradient1", 26 | _type = "cc.LayerGradient", 27 | height = 50, 28 | ignoreAnchor = 1, 29 | width = 900, 30 | x = 450, 31 | y = 500, 32 | anchor = { 33 | x = 0.5, 34 | y = 1}, 35 | endColor = { 36 | a = 255, 37 | b = 220, 38 | g = 220, 39 | r = 220}, 40 | startColor = { 41 | a = 255, 42 | b = 230, 43 | g = 230, 44 | r = 230}, 45 | _children = { { 46 | _id = "titleLabel", 47 | _type = "cc.Label", 48 | color = "141414", 49 | fontSize = 36, 50 | scaleX = 0.5, 51 | scaleY = 0.5, 52 | string = "Oops!", 53 | x = 450, 54 | y = 25}, 55 | { 56 | _id = "closeBtn", 57 | _type = "ZoomButton", 58 | scaleX = 0.7, 59 | scaleY = 0.7, 60 | x = 895, 61 | y = 26, 62 | anchor = { 63 | x = 1, 64 | y = 0.5}, 65 | _children = { { 66 | _id = "sprite1", 67 | _lock = 0, 68 | _type = "cc.Sprite", 69 | file = "gk/res/texture/close.png", 70 | x = 54, 71 | y = 40}}}}}, 72 | { 73 | _id = "contentLabel", 74 | _type = "cc.Label", 75 | color = "141414", 76 | fontSize = 32, 77 | scaleX = 0.5, 78 | scaleY = 0.5, 79 | string = "label", 80 | width = 1600, 81 | x = 450, 82 | y = 425, 83 | anchor = { 84 | x = 0.5, 85 | y = 1}}}}}} -------------------------------------------------------------------------------- /src/gk/node/ToggleButton.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/18 5 | -- Time: 上午11:44 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local ZoomButton = import(".ZoomButton") 10 | local ToggleButton = class("ToggleButton", ZoomButton) 11 | 12 | function ToggleButton:ctor(...) 13 | ToggleButton.super.ctor(self, ...) 14 | self.autoToggle = false 15 | end 16 | 17 | function ToggleButton:setAutoToggle(var) 18 | self.autoToggle = var 19 | end 20 | 21 | function ToggleButton:isAutoToggle() 22 | return self.autoToggle 23 | end 24 | 25 | function ToggleButton:_addChild(child, zorder, tag) 26 | if tag then 27 | self.__addChild(self, child, zorder, tag) 28 | elseif zorder then 29 | self.__addChild(self, child, zorder) 30 | else 31 | self.__addChild(self, child) 32 | end 33 | local tg = child:getTag() 34 | local isDebugNode = gk.util:isDebugTag(tg) 35 | if not self.contentNode and not isDebugNode then 36 | self:setContentNode(child) 37 | end 38 | 39 | if tg ~= -1 and not isDebugNode then 40 | child:setVisible(tg ~= -1 and tg == self:getSelectedTag()) 41 | end 42 | end 43 | 44 | function ToggleButton:setSelectedTag(tag) 45 | local children = self:getChildren() 46 | for i = 1, #children do 47 | local child = children[i] 48 | if child and child:getTag() ~= -1 and not gk.util:isDebugNode(child) then 49 | child:setVisible(tag ~= -1 and child:getTag() == tag) 50 | end 51 | end 52 | if self.selectedTag ~= tag then 53 | -- gk.log("setSelectedTag %s", tag) 54 | self.selectedTag = tag 55 | if self.onSelectedTagChangedCallback then 56 | self.onSelectedTagChangedCallback(self, tag) 57 | end 58 | end 59 | end 60 | 61 | function ToggleButton:getSelectedTag() 62 | return self.selectedTag or 0 63 | end 64 | 65 | function ToggleButton:onSelectedTagChanged(callback) 66 | self.onSelectedTagChangedCallback = callback 67 | end 68 | 69 | function ToggleButton:activate() 70 | if self.enabled then 71 | if self.autoToggle then 72 | local tag = self:getSelectedTag() 73 | if tag > 0 then 74 | while true do 75 | local next = self:getChildByTag(tag + 1) 76 | if next then 77 | self:setSelectedTag(tag + 1) 78 | break 79 | elseif tag == 0 then 80 | break 81 | else 82 | tag = 0 83 | end 84 | end 85 | end 86 | end 87 | ToggleButton.super.activate(self) 88 | end 89 | end 90 | 91 | return ToggleButton -------------------------------------------------------------------------------- /src/gk/controller/shader.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/21/17 5 | -- Time: 16:15 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local shader = {} 10 | 11 | shader.cachedGLPrograms = {} 12 | function shader:addGLProgram(vPath, fPath) 13 | local glProgram = cc.GLProgram:createWithFilenames(vPath, fPath) 14 | if glProgram then 15 | local ps = string.split(fPath, "/") 16 | local key = string.split(ps[#ps], ".")[1] 17 | gk.log("addGLProgram -> %s, fPath = %s", key, fPath) 18 | cc.GLProgramCache:getInstance():addGLProgram(glProgram, key) 19 | self.cachedGLPrograms[key] = { shader = glProgram, vPath = vPath, fPath = fPath } 20 | end 21 | end 22 | 23 | function shader:getCachedGLProgram(key) 24 | return cc.GLProgramCache:getInstance():getGLProgram(key) 25 | -- return self.cachedGLPrograms[key] and self.cachedGLPrograms[key].shader or nil 26 | end 27 | 28 | function shader:reloadOnRenderRecreated() 29 | if not self.recreateListener then 30 | local eventDispatcher = cc.Director:getInstance():getEventDispatcher() 31 | local customListener = cc.EventListenerCustom:create("event_renderer_recreated", function(event) 32 | gk.log("reload shader onRenderRecreated") 33 | if self.cachedGLPrograms then 34 | for _, info in pairs(self.cachedGLPrograms) do 35 | local shader = info.shader 36 | shader:reset() 37 | shader:initWithFilenames(info.vPath, info.fPath) 38 | shader:bindAttribLocation(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION) 39 | shader:bindAttribLocation(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR) 40 | shader:bindAttribLocation(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORD) 41 | shader:link() 42 | shader:updateUniforms() 43 | end 44 | end 45 | end) 46 | 47 | eventDispatcher:addEventListenerWithFixedPriority(customListener, -1) 48 | self.recreateListener = customListener 49 | end 50 | end 51 | 52 | function shader:removeRecreateListener() 53 | if self.recreateListener then 54 | local eventDispatcher = cc.Director:getInstance():getEventDispatcher() 55 | eventDispatcher:removeEventListener(self.recreateListener) 56 | self.recreateListener = nil 57 | end 58 | end 59 | 60 | function shader:getDefaultShader() 61 | return cc.GLProgramCache:getInstance():getGLProgram("ShaderPositionTextureColor_noMVP") 62 | end 63 | 64 | function shader:getDefaultMvpShader() 65 | return cc.GLProgramCache:getInstance():getGLProgram("ShaderPositionTextureColor_MVP") 66 | end 67 | 68 | return shader 69 | -------------------------------------------------------------------------------- /src/gk/core/audio.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 6/12/17 5 | -- Time: 16:52 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local audio = {} 10 | 11 | local engine = cc.SimpleAudioEngine:getInstance() 12 | function audio:init() 13 | self.audios = {} 14 | self.seOn = cc.UserDefault:getInstance():getBoolForKey("gk_seOn", true) 15 | self.bgmOn = cc.UserDefault:getInstance():getBoolForKey("gk_bgmOn", true) 16 | end 17 | 18 | function audio:isSeOn() 19 | return self.seOn 20 | end 21 | 22 | function audio:isBgmOn() 23 | return self.bgmOn 24 | end 25 | 26 | function audio:setSeOn(var) 27 | if self.seOn ~= var then 28 | self.seOn = var 29 | cc.UserDefault:getInstance():setBoolForKey("gk_seOn", var) 30 | cc.UserDefault:getInstance():flush() 31 | end 32 | end 33 | 34 | function audio:setBgmOn(var) 35 | if self.bgmOn ~= var then 36 | self.bgmOn = var 37 | cc.UserDefault:getInstance():setBoolForKey("gk_bgmOn", var) 38 | cc.UserDefault:getInstance():flush() 39 | if not var then 40 | self:stopMusic() 41 | else 42 | self:playMusic(self.music, self.loop) 43 | end 44 | end 45 | end 46 | 47 | function audio:registerEvent(sid, path, tag) 48 | self.audios[sid] = { path = path, tag = tag } 49 | end 50 | 51 | function audio:isValidEvent(sid) 52 | return self.audios[sid] 53 | end 54 | 55 | function audio:preloadEffect(sid) 56 | local s = self.audios[sid] 57 | if s then 58 | engine:preloadEffect(s.path) 59 | end 60 | end 61 | 62 | function audio:unloadEffect(sid) 63 | local s = self.audios[sid] 64 | if s then 65 | engine:unloadEffect(s.path) 66 | end 67 | end 68 | 69 | function audio:preloadEffectByTag(tag) 70 | -- TODO 71 | end 72 | 73 | function audio:unloadEffectByTag(tag) 74 | -- TODO 75 | end 76 | 77 | function audio:preloadMusic(sid) 78 | local s = self.audios[sid] 79 | if s then 80 | engine:preloadMusic(s.path) 81 | end 82 | end 83 | 84 | function audio:playEffect(sid, isLoop) 85 | if self.seOn then 86 | local s = self.audios[sid] 87 | if s then 88 | engine:playEffect(s.path, isLoop) 89 | end 90 | end 91 | end 92 | 93 | function audio:playMusic(sid, isLoop) 94 | if self.bgmOn then 95 | local s = self.audios[sid] 96 | if s then 97 | engine:playMusic(s.path, isLoop) 98 | end 99 | end 100 | self.music = sid 101 | self.loop = isLoop 102 | end 103 | 104 | function audio:stopMusic(releaseData) 105 | cc.SimpleAudioEngine:getInstance():stopMusic(releaseData) 106 | end 107 | 108 | return audio -------------------------------------------------------------------------------- /src/gk/core/init.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/12/29 5 | -- Time: 上午10:12 6 | -- To change this template use File | Settings | File Templates. 7 | 8 | import(".List") 9 | import(".log") 10 | gk.event = import(".event") 11 | gk.event:init() 12 | gk.audio = import(".audio") 13 | gk.audio:init() 14 | gk.injector = import(".injector") 15 | gk.injector:init() 16 | gk.display = import(".display") 17 | gk.generator = import(".generator") 18 | 19 | ----------------------------------- runtime version for mac editor -------------------------------------------- 20 | 21 | if cc.Application:getInstance():getTargetPlatform() ~= 2 then 22 | -- runtime version is valid only on mac and edit mode 23 | gk.runtimeVersion = "" 24 | end 25 | 26 | -- xx.xx.xx.xx 27 | gk.getRuntimeVersion = function() 28 | if gk.runtimeVersion then 29 | return gk.runtimeVersion 30 | end 31 | local version 32 | if cc.Application:getInstance():getTargetPlatform() == 2 then 33 | local path = cc.FileUtils:getInstance():fullPathForFilename("gk/core/runtimeversion.lua") 34 | if path and path ~= "" then 35 | package.loaded[path] = nil 36 | local status, result = pcall(require, path) 37 | if status then 38 | gk.runtimeVersion = result.version 39 | return result.version 40 | else 41 | local table2lua = require("gk.tools.table2lua") 42 | if not gk.errorOccurs then 43 | io.writefile(path, table2lua.encode_pretty({ version })) 44 | end 45 | end 46 | else 47 | local path = cc.FileUtils:getInstance():fullPathForFilename("gk/core/init.lua") 48 | local pos = string.find(path, "/init.lua") 49 | if pos then 50 | path = path:sub(1, pos - 1) .. "/runtimeversion.lua" 51 | local table2lua = require("gk.tools.table2lua") 52 | if not gk.errorOccurs then 53 | io.writefile(path, table2lua.encode_pretty({ version = "0.0.0.0" })) 54 | end 55 | end 56 | end 57 | end 58 | return "0.0.0.0" 59 | end 60 | 61 | gk.increaseRuntimeVersion = function() 62 | if cc.Application:getInstance():getTargetPlatform() == 2 then 63 | local version = gk:getRuntimeVersion() 64 | local vs = string.split(version, ".") 65 | vs[#vs] = tostring(tonumber(vs[#vs]) + 1) 66 | version = table.concat(vs, ".") 67 | gk.runtimeVersion = version 68 | local table2lua = require("gk.tools.table2lua") 69 | if not gk.errorOccurs then 70 | local path = cc.FileUtils:getInstance():fullPathForFilename("gk/core/runtimeversion.lua") 71 | io.writefile(path, table2lua.encode_pretty({ version = version })) 72 | end 73 | end 74 | end -------------------------------------------------------------------------------- /src/main.lua: -------------------------------------------------------------------------------- 1 | if jit and jit.status() then 2 | -- turn jit off, use interpreter mode, that's faster on Android 3 | jit.off() 4 | jit.flush() 5 | end 6 | print("main(main.lua gk/hotUpdate.lua gk/instanceRun version.lua cannot be reloaded when running!)") 7 | 8 | -- init default search path 9 | cc.FileUtils:getInstance():addSearchPath("src/") 10 | cc.FileUtils:getInstance():addSearchPath("res/") 11 | cc.FileUtils:getInstance():setPopupNotify(false) 12 | -- keep orign package path 13 | local orignPackagePath = package.path 14 | 15 | local function clearModules() 16 | print("clearModules") 17 | local __g = _G 18 | setmetatable(__g, {}) 19 | 20 | package.path = orignPackagePath 21 | 22 | local whitelist = { 23 | ["string"] = true, 24 | ["io"] = true, 25 | ["pb"] = true, 26 | ["bit"] = true, 27 | ["os"] = true, 28 | ["debug"] = true, 29 | ["table"] = true, 30 | ["math"] = true, 31 | ["package"] = true, 32 | ["coroutine"] = true, 33 | ["pack"] = true, 34 | ["jit"] = true, 35 | ["jit.util"] = true, 36 | ["jit.opt"] = true, 37 | ["lfs"] = true, 38 | ["main"] = true, 39 | ["gk.instanceRun"] = true, 40 | ["version"] = true, 41 | } 42 | 43 | for p, _ in pairs(package.loaded) do 44 | if not whitelist[p] then 45 | print (p) 46 | package.loaded[p] = nil 47 | end 48 | end 49 | end 50 | 51 | print(string.format("package.path = \"%s\"", package.path)) 52 | local searchPath = cc.FileUtils:getInstance():getSearchPaths() 53 | print("app search paths:") 54 | for _, v in ipairs(searchPath) do 55 | print(string.format("searchPath:\"%s\"", v)) 56 | end 57 | 58 | local function initInstanceRun(android_package_name) 59 | local instanceRun = require("gk.instanceRun") 60 | instanceRun:init(android_package_name) 61 | end 62 | 63 | local function initHotUpdate() 64 | local hotUpdate = require("gk.hotUpdate") 65 | local codeVersion = require("version") 66 | hotUpdate:init(codeVersion) 67 | end 68 | 69 | local function startGame(mode) 70 | return require("init"):startGame(mode) 71 | end 72 | 73 | -- will be called in some other place to restart game 74 | function restartGame(mode) 75 | print("restartGame") 76 | clearModules() 77 | startGame(mode) 78 | end 79 | 80 | -- 0: release mode 81 | -- 1: edit mode 82 | if cc.Application:getInstance():getTargetPlatform() == 2 then 83 | --- mac default run with edit mode with instance run enabled 84 | initInstanceRun() -- instance run on Mac, with ui editor 85 | startGame(1) 86 | -- initHotUpdate() -- enable hot update on Mac 87 | -- startGame(0) 88 | else 89 | -- initInstanceRun("com.demo.gk) -- instance run on Android, disabled this before publish 90 | initHotUpdate() -- enable hot update on Android 91 | startGame(0) 92 | end 93 | -------------------------------------------------------------------------------- /src/gk/node/Scene.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/4/8 5 | -- Time: 上午11:22 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | -- for wrap node 10 | local Scene = class("Scene", function() 11 | return cc.Scene:create() 12 | end) 13 | 14 | function Scene:ctor(sceneType) 15 | self.__sceneType = sceneType 16 | if gk.displayRuntimeVersion then 17 | local version = "" 18 | local curVersion = cc.UserDefault:getInstance():getStringForKey("gk_currentVersion", "") 19 | if curVersion ~= "" then 20 | version = version .. curVersion 21 | end 22 | local sid = SERVER_ID or "" 23 | if sid ~= "" then 24 | version = version .. "/s" .. sid 25 | end 26 | local rv = gk:getRuntimeVersion() 27 | if rv and rv ~= "" then 28 | if version ~= "" then 29 | version = version .. "/" .. rv 30 | else 31 | version = rv 32 | end 33 | end 34 | local label = gk.create_label(version, "Arial", 15) 35 | gk.set_label_color(label, cc.c3b(230, 230, 230)) 36 | local node = cc.Node:create() 37 | node:setContentSize(cc.size(120, 30)) 38 | label:setAnchorPoint(cc.p(1, 0)) 39 | label:setPosition(cc.p(120 - 3, 2)) 40 | node:addChild(label) 41 | local button = gk.ZoomButton.new(node) 42 | label:setTag(gk.util.tags.versionTag) 43 | self:addChild(button, 9999999) 44 | button:setAnchorPoint(cc.p(1, 0)) 45 | button:setScale(gk.display:minScale()) 46 | button:setPosition((gk.display.leftWidth or 0) + (gk.display.extWidth / 2 or 0) + (gk.display.iPhoneXExtWidth / 2 or 0) + gk.display:scaleX(gk.display:designSize().width - 1), gk.display.bottomHeight or 0) 47 | button:onClicked(function() 48 | gk.config:openConfigDialog() 49 | end) 50 | end 51 | 52 | if gk.display:iPhoneX() and gk.mode == gk.MODE_RELEASE and cc.Application:getInstance():getTargetPlatform() == 2 then 53 | local overlay = gk.create_sprite("gk/res/texture/ipx.png") 54 | self:addChild(overlay, 9999999) 55 | overlay:setColor(cc.c3b(26, 26, 26)) 56 | overlay:setScale(self:getContentSize().width / overlay:getContentSize().width) 57 | overlay:setPosition(self:getContentSize().width / 2, self:getContentSize().height / 2) 58 | end 59 | end 60 | 61 | function Scene:showDialog(dialogName, ...) 62 | if self.layer then 63 | self.layer:showDialog(dialogName, ...) 64 | else 65 | gk.log("%s:showDialog error, cannot find layer --> %s", self.layerName, dialogName) 66 | end 67 | end 68 | 69 | function Scene:showDialogNode(dialogNode) 70 | if self.layer then 71 | self.layer:showDialogNode(dialogNode) 72 | else 73 | gk.log("%s:showDialogNode error, cannot find layer", self.layerName) 74 | end 75 | end 76 | 77 | return Scene -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_shadertest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = true, 3 | _id = "shaderTest1", 4 | height = "$fill", 5 | width = "$fill", 6 | _children = { { 7 | _id = "label1", 8 | _type = "cc.Label", 9 | fontSize = 16, 10 | scaleX = "$minScale", 11 | scaleY = "$minScale", 12 | string = "None", 13 | x = 60, 14 | y = 680, 15 | anchor = { 16 | x = 0, 17 | y = 0.5}, 18 | scaleXY = { 19 | x = "$scaleX", 20 | y = "$scaleY"}, 21 | _children = { { 22 | _id = "sprite1", 23 | _type = "cc.Sprite", 24 | file = "gk/res/texture/icon_cocos.png", 25 | y = -10, 26 | anchor = { 27 | x = 0, 28 | y = 1}}}}, 29 | { 30 | _id = "label2", 31 | _type = "cc.Label", 32 | fontSize = 16, 33 | scaleX = "$minScale", 34 | scaleY = "$minScale", 35 | string = "Highlight", 36 | x = 200, 37 | y = 680, 38 | anchor = { 39 | x = 0, 40 | y = 0.5}, 41 | scaleXY = { 42 | x = "$scaleX", 43 | y = "$scaleY"}, 44 | _children = { { 45 | GLProgram = "HighLight", 46 | _id = "sprite2", 47 | _type = "cc.Sprite", 48 | file = "gk/res/texture/icon_cocos.png", 49 | y = -10, 50 | anchor = { 51 | x = 0, 52 | y = 1}}}}, 53 | { 54 | _id = "label3", 55 | _type = "cc.Label", 56 | fontSize = 16, 57 | scaleX = "$minScale", 58 | scaleY = "$minScale", 59 | string = "Freeze", 60 | x = 340, 61 | y = 680, 62 | anchor = { 63 | x = 0, 64 | y = 0.5}, 65 | scaleXY = { 66 | x = "$scaleX", 67 | y = "$scaleY"}, 68 | _children = { { 69 | GLProgram = "Freeze", 70 | _id = "sprite3", 71 | _type = "cc.Sprite", 72 | file = "gk/res/texture/icon_cocos.png", 73 | y = -10, 74 | anchor = { 75 | x = 0, 76 | y = 1}}}}, 77 | { 78 | _id = "label4", 79 | _type = "cc.Label", 80 | fontSize = 16, 81 | scaleX = "$minScale", 82 | scaleY = "$minScale", 83 | string = "GrayScale", 84 | x = 480, 85 | y = 680, 86 | anchor = { 87 | x = 0, 88 | y = 0.5}, 89 | fontFile = { 90 | en = "Arial"}, 91 | scaleXY = { 92 | x = "$scaleX", 93 | y = "$scaleY"}, 94 | _children = { { 95 | GLProgram = "ShaderUIGrayScale", 96 | _id = "sprite4", 97 | _type = "cc.Sprite", 98 | file = "gk/res/texture/icon_cocos.png", 99 | y = -10, 100 | anchor = { 101 | x = 0, 102 | y = 1}}}}}} -------------------------------------------------------------------------------- /src/gk/test/TableViewTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/1/25 5 | -- Time: 下午5:28 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local TableViewTest = class("TableViewTest", gk.Layer) 10 | 11 | function TableViewTest:ctor() 12 | TableViewTest.super.ctor(self) 13 | -- let height fill screen 14 | local height = gk.display:designSize().height / gk.display:minScale() * gk.display:yScale() 15 | self.layerColor1:setContentSize(cc.size(self.layerColor1:getContentSize().width, height)) 16 | self.tableView1:setViewSize(cc.size(self.tableView1:getViewSize().width, height)) 17 | self:setData() 18 | self.tableView1:reloadData() 19 | end 20 | 21 | function TableViewTest:cellNumForTable(table) 22 | return #self:getData() 23 | end 24 | 25 | function TableViewTest:cellSizeForTable(table, idx) 26 | local dt = self:getData()[idx + 1] 27 | -- use size model to calculate cell height dynamically 28 | if not dt.height then 29 | self.cellModel = self.cellModel or gk.injector:inflateNode("gk.test.cell.TableCell1") 30 | self.cellModel:setData(dt) 31 | dt.height = self.cellModel.cellHeight 32 | dt.width = self.cellModel:getContentSize().width 33 | end 34 | return dt.width, dt.height 35 | end 36 | 37 | function TableViewTest:cellAtIndex(table, idx) 38 | local dt = self:getData()[idx + 1] 39 | local cell = table:dequeueCell() 40 | if nil == cell then 41 | cell = gk.injector:inflateNode("gk.test.cell.TableCell1") 42 | end 43 | cell:setData(dt) 44 | return cell 45 | end 46 | 47 | function TableViewTest:getData() 48 | return self.data or {} 49 | end 50 | 51 | function TableViewTest:setData() 52 | self.data = { 53 | { type = "Time", content = "00:00 AM" }, 54 | { type = "Me", content = "Hello!" }, 55 | { type = "Member", content = "Fell well" }, 56 | { type = "Member", content = "Additive blending is the type of blending we do when we add different colors together and add the result." }, 57 | { type = "Time", content = "11:30 AM" }, 58 | { type = "Me", content = "This is the way that our vision works together with light and this is how we can perceive millions of different colors on our monitors." }, 59 | { type = "Member", content = "Free" }, 60 | { type = "Me", content = "Oops" }, 61 | { type = "Member", content = "I say this as a former Secretary of State and as an American: the Russians are still coming. Our intelligence professionals are imploring Trump to act. Will he continue to ignore & surrender, or protect our country?" }, 62 | { type = "Time", content = "1:30 PM" }, 63 | { type = "Me", content = "OMG" }, 64 | { type = "Member", content = "If schools are mandated to be gun free zones, violence and danger are given an open invitation to enter. Almost all school shootings are in gun free zones. Cowards will only go where there is no deterrent!" }, 65 | { type = "Time", content = "13:12" }, 66 | { type = "Me", content = "Will be making a decision soon on the appointment of new Chief Economic Advisor. Many people wanting the job - will choose wisely!" }, 67 | { type = "Time", content = "11:30" }, 68 | { type = "Member", content = "The United States has an $800 Billion Dollar Yearly Trade Deficit because of our “very stupid” trade deals and policies. Our jobs and wealth are being given to other countries that have taken advantage of us for years. They laugh at what fools our leaders have been. No more!" }, 69 | } 70 | end 71 | 72 | return TableViewTest -------------------------------------------------------------------------------- /src/gk/node/ZoomButton.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/11/25 5 | -- Time: 上午10:48 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local Button = import(".Button") 10 | local ZoomButton = class("ZoomButton", Button) 11 | -- TODO: use global 12 | local kZoomActionTag = -0xFFFFF1 13 | 14 | function ZoomButton:ctor(...) 15 | self.zoomScale = 1 16 | self.zoomEnabled = true 17 | ZoomButton.super.ctor(self, ...) 18 | end 19 | 20 | function ZoomButton:setContentNode(node) 21 | ZoomButton.super.setContentNode(self, node) 22 | -- default scale 23 | local width = self:getContentSize().width 24 | if width <= 100 then 25 | self.zoomScale = 0.9 26 | elseif width <= 200 then 27 | self.zoomScale = 0.9 + 0.05 / 100 * (width - 100) 28 | elseif width <= 500 then 29 | self.zoomScale = 0.95 + 0.04 / 300 * (width - 200) 30 | else 31 | self.zoomScale = 0.99 32 | end 33 | end 34 | 35 | function ZoomButton:setZoomScale(scale) 36 | self.zoomScale = scale 37 | end 38 | 39 | function ZoomButton:getZoomScale() 40 | return self.zoomScale 41 | end 42 | 43 | function ZoomButton:setZoomEnabled(enabled) 44 | self.zoomEnabled = enabled 45 | end 46 | 47 | function ZoomButton:isZoomEnabled() 48 | return self.zoomEnabled 49 | end 50 | 51 | function ZoomButton:setSafeAnchor(anchorX, anchorY) 52 | local contentSize = self:getContentSize() 53 | local oldAnchor = self:getAnchorPoint() 54 | local diffX = (anchorX - oldAnchor.x) * contentSize.width * self.originalScaleX 55 | local diffY = (anchorY - oldAnchor.y) * contentSize.height * self.originalScaleY 56 | self:setAnchorPoint(cc.p(anchorX, anchorY)) 57 | self:setPositionX(self:getPositionX() + diffX) 58 | self:setPositionY(self:getPositionY() + diffY) 59 | end 60 | 61 | function ZoomButton:setSelected(selected) 62 | if self.enabled and selected ~= self.selected and self.zoomEnabled then 63 | -- gk.log("ZoomButton:selected") 64 | if selected then 65 | local action = self:getActionByTag(kZoomActionTag) 66 | if action then 67 | self:stopAction(action) 68 | else 69 | self.originalScaleX = self:getScaleX() 70 | self.originalScaleY = self:getScaleY() 71 | end 72 | 73 | local zoomAction = cc.ScaleTo:create(0.03, self.originalScaleX * self.zoomScale, self.originalScaleY * self.zoomScale) 74 | zoomAction:setTag(kZoomActionTag) 75 | self:runAction(zoomAction) 76 | 77 | self.originalAnchor = self:getAnchorPoint() 78 | self:setSafeAnchor(0.5, 0.5) 79 | else 80 | gk.util:stopActionByTagSafe(self, kZoomActionTag) 81 | local action1 = cc.ScaleTo:create(0.04, self.originalScaleX * (1 + (1 - self.zoomScale) / 2), self.originalScaleY * (1 + (1 - self.zoomScale) / 2)) 82 | local action2 = cc.ScaleTo:create(0.04, 0.5 * self.originalScaleX * (self.zoomScale + 1), 0.5 * self.originalScaleY * (self.zoomScale + 1)) 83 | local action3 = cc.ScaleTo:create(0.06, self.originalScaleX, self.originalScaleY) 84 | local actionAll = cc.Sequence:create(action1, action2, action3) 85 | local zoomAction = cc.Sequence:create(actionAll, cc.CallFunc:create(function() 86 | self:setSafeAnchor(self.originalAnchor.x, self.originalAnchor.y) 87 | end)) 88 | zoomAction:setTag(kZoomActionTag) 89 | self:runAction(zoomAction) 90 | end 91 | end 92 | ZoomButton.super.setSelected(self, selected) 93 | end 94 | 95 | return ZoomButton -------------------------------------------------------------------------------- /src/gk/core/event.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/12/29 5 | -- Time: 上午10:12 6 | -- To change this template use File | Settings | File Templates. 7 | 8 | local event = {} 9 | 10 | function event:init() 11 | gk.log("event:init") 12 | self._listeners = {} 13 | gk.eventNames = {} 14 | end 15 | 16 | function event:subscribe(target, eventName, callback) 17 | -- self:checkValidEventName(eventName) 18 | local listeners = self._listeners[eventName] 19 | if not listeners then 20 | listeners = { { tg = target, en = eventName, cb = callback, valid = true } } 21 | self._listeners[eventName] = listeners 22 | else 23 | for _, l in ipairs(listeners) do 24 | if l.tg == target and l.en == eventName then 25 | gk.log("[warning] cannot add event listener multi-times for the same target! eventName = %s", eventName) 26 | return 27 | end 28 | end 29 | table.insert(listeners, { tg = target, en = eventName, cb = callback, valid = true }) 30 | end 31 | -- gk.log("event:subscribe %s, taget = %s", eventName, target.__cname) 32 | end 33 | 34 | function event:unsubscribe(target, eventName) 35 | local listeners = self._listeners[eventName] 36 | if listeners and #listeners > 0 then 37 | local validList = {} 38 | for _, l in ipairs(listeners) do 39 | if l.tg == target and l.en == eventName then 40 | l.valid = false 41 | elseif l.valid then 42 | table.insert(validList, l) 43 | end 44 | end 45 | if #validList == 0 then 46 | -- gk.log("event:unsubscribe %s, target = %s, targetCount = 0", eventName, target.__cname) 47 | self._listeners[eventName] = nil 48 | else 49 | self._listeners[eventName] = validList 50 | -- gk.log("event:unsubscribe %s, target = %s, targetCount = %d", eventName, target.__cname, #validList) 51 | end 52 | end 53 | end 54 | 55 | function event:unsubscribeAll(target) 56 | for eventName, listeners in pairs(self._listeners) do 57 | if listeners and #listeners > 0 then 58 | local validList = {} 59 | for _, l in ipairs(listeners) do 60 | if l.tg == target then 61 | l.valid = false 62 | elseif l.valid then 63 | table.insert(validList, l) 64 | end 65 | end 66 | if #validList == 0 then 67 | -- gk.log("event:unsubscribe %s, target = %s, targetCount = 0", eventName, target.__cname) 68 | self._listeners[eventName] = nil 69 | else 70 | self._listeners[eventName] = validList 71 | -- gk.log("event:unsubscribe %s, target = %s, targetCount = %d", eventName, target.__cname, #validList) 72 | end 73 | end 74 | end 75 | end 76 | 77 | function event:post(eventName, ...) 78 | -- self:checkValidEventName(eventName) 79 | -- gk.log("event:post --> %s", eventName) 80 | local listeners = self._listeners[eventName] 81 | if listeners and #listeners > 0 then 82 | local copy = clone(listeners) 83 | for _, l in ipairs(copy) do 84 | if l.valid and l.cb then 85 | l.cb(...) 86 | end 87 | end 88 | else 89 | -- gk.log("event:post(%s), no target to receive event!", eventName) 90 | end 91 | end 92 | 93 | function event:registerEventName(eventName) 94 | gk.eventNames[eventName] = true 95 | end 96 | 97 | function event:checkValidEventName(eventName) 98 | if gk.mode ~= gk.MODE_EDIT then 99 | if gk.eventNames[eventName] then 100 | return true 101 | else 102 | -- gk.log("waring! unregisterEventName %s", eventName) 103 | end 104 | else 105 | return true 106 | end 107 | end 108 | 109 | return event -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cocos2dx-lua-ui-editor 2 | A lightweight ui editor for cocos2d-x-lua implemented by pure lua code, less than 10000 lines of code. 3 | 4 | [![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Tencent/xLua/blob/master/LICENSE.TXT) 5 | 6 | ### LabelTest 7 | ![alt tag](snapshots/ss1.png) 8 | ### TableViewTest on ScreenSize 1280x720 9 | ![alt tag](snapshots/ss2.png) 10 | ### TableViewTest on ScreenSize 1280x960 11 | ![alt tag](snapshots/ss3.png) 12 | 13 | ## Features 14 | * No dependency except cocos2d-x-lua lib (Tested on 3.15). 15 | * Instance Run&Edit on Mac, F1:EditMode, F2:ReleaseMode(Editing node), F3:ReleaseMode, Hot deploy on Android Device. 16 | * Support almost all cocos2d-x nodes and lots of custom nodes. 17 | * 4 root containers: gk.Layer, gk.Dialog, gk.Widget, gk.TableViewCell. 18 | * Completely compatible with ui created by code. 19 | * Layout files are generated as lua code, no parser. 20 | * Screen adapt policy: FIXED_WIDTH, FIXED_HEIGHT, UNIVERSAL(Scale coordinates and nodes separately), support iPhoneX. 21 | * FSM Editor, BehaviorTree Editor; 22 | 23 | ## How to use 24 | 1. Create an empty lua-project by cocos2d-x 3.15. 25 | 2. Copy "gk/" dir to "src/". 26 | 3. Init gamekit correctly. 27 | 4. Build app and run by Xcode, then you can directly run use "runtime/mac/<youapp>.app". 28 | 29 | ## Example 30 | * Create a file and Class named ChatCell, refresh Editor by F1. 31 | ```lua 32 | local ChatCell = class("ChatCell", gk.TableViewCell) 33 | 34 | return ChatCell 35 | ``` 36 | 37 | * Edit the layout in editor. 38 | ![alt tag](snapshots/ss4.png) 39 | 40 | * Inflate cell just by one line code. 41 | ```lua 42 | local cell = gk.injector:inflateNode("demoapp.ChatCell") 43 | ``` 44 | 45 | * Auto generated layout code. 46 | ```lua 47 | -- demoapp/gen/layout/demoapp_chatcell.lua 48 | return { 49 | _id = "ChatCell", 50 | _type = "ChatCell", 51 | height = 120, 52 | scaleX = "$xScale", 53 | scaleY = "$xScale", 54 | width = 720, 55 | anchor = { 56 | x = 0, 57 | y = 0}, 58 | _children = { { 59 | _id = "layerColor1", 60 | _type = "cc.LayerColor", 61 | height = "$fill", 62 | width = "$fill", 63 | _children = { { 64 | _id = "bottomLine", 65 | _type = "cc.LayerColor", 66 | color = "f0f0f0ff", 67 | height = 1, 68 | width = "$fill"}, 69 | { 70 | _id = "avatar", 71 | _type = "cc.Sprite", 72 | file = "main/avatar.png", 73 | x = 61, 74 | y = 60}, 75 | { 76 | _id = "nickName", 77 | _type = "cc.Label", 78 | color = "000000", 79 | fontSize = 32, 80 | height = 0, 81 | string = "NickName", 82 | width = 0, 83 | x = 120, 84 | y = 74, 85 | anchor = { 86 | x = 0, 87 | y = 0.5}}, 88 | { 89 | _id = "desc", 90 | _type = "cc.Label", 91 | color = "a6a6a6", 92 | enableWrap = true, 93 | fontSize = 20, 94 | height = 0, 95 | overflow = 2, 96 | string = "[Message]", 97 | width = 500, 98 | x = 120, 99 | y = 40, 100 | anchor = { 101 | x = 0, 102 | y = 0.5}}, 103 | { 104 | _id = "time", 105 | _type = "cc.Label", 106 | color = "a6a6a6", 107 | fontSize = 20, 108 | height = 0, 109 | string = "13:57", 110 | width = 0, 111 | x = 686, 112 | y = 80, 113 | anchor = { 114 | x = 1, 115 | y = 0.5}}, 116 | { 117 | _id = "dot", 118 | _type = "cc.Sprite", 119 | color = "ff0000", 120 | file = "main/dot.png", 121 | x = 95, 122 | y = 93}}}}} 123 | ``` 124 | 125 | ## TODO 126 | * Dynamic inflate nodes when needed :) 127 | * 3D support, but the cocos3D is too weak :( 128 | * Document. 129 | -------------------------------------------------------------------------------- /src/gk/res/particle/Galaxy.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | angle 6 | 90 7 | angleVariance 8 | 360 9 | blendFuncDestination 10 | 1 11 | blendFuncSource 12 | 770 13 | duration 14 | -1 15 | emitterType 16 | 0.0 17 | finishColorAlpha 18 | 1 19 | finishColorBlue 20 | 0.0 21 | finishColorGreen 22 | 0.0 23 | finishColorRed 24 | 0.0 25 | finishColorVarianceAlpha 26 | 0.0 27 | finishColorVarianceBlue 28 | 0.0 29 | finishColorVarianceGreen 30 | 0.0 31 | finishColorVarianceRed 32 | 0.0 33 | finishParticleSize 34 | 37 35 | finishParticleSizeVariance 36 | 0.0 37 | gravityx 38 | 0.0 39 | gravityy 40 | 0.0 41 | maxParticles 42 | 934 43 | maxRadius 44 | 276.20999145507812 45 | maxRadiusVariance 46 | 154.94999694824219 47 | minRadius 48 | 0.0 49 | particleLifespan 50 | 4 51 | particleLifespanVariance 52 | 1 53 | radialAccelVariance 54 | 0.0 55 | radialAcceleration 56 | -20 57 | rotatePerSecond 58 | 35.529998779296875 59 | rotatePerSecondVariance 60 | 0.0 61 | sourcePositionVariancex 62 | 0.0 63 | sourcePositionVariancey 64 | 0.0 65 | sourcePositionx 66 | 169.91000366210938 67 | sourcePositiony 68 | 228.71000671386719 69 | speed 70 | 59.209999084472656 71 | speedVariance 72 | 10 73 | startColorAlpha 74 | 1 75 | startColorBlue 76 | 0.75999999046325684 77 | startColorGreen 78 | 0.25 79 | startColorRed 80 | 0.11999999731779099 81 | startColorVarianceAlpha 82 | 0.0 83 | startColorVarianceBlue 84 | 0.0 85 | startColorVarianceGreen 86 | 0.0 87 | startColorVarianceRed 88 | 0.0 89 | startParticleSize 90 | 37 91 | startParticleSizeVariance 92 | 10 93 | tangentialAccelVariance 94 | 50 95 | tangentialAcceleration 96 | 50 97 | textureFileName 98 | Galaxy.png 99 | textureImageData 100 | H4sIAAAAAAAAAwFmA5n8iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAADLUlEQVRYCcXX51JbQRCEUeOc/f6v6ZzxHKFPLAoI84epmrp7985294QVxcXl5eWjh7Sn9yB/MWcej19sXQb87/iP8f+yiztWAOmzcYL5k/F9AX9m7/fWf83zTmLOVeD5AHECWieiKpR95D8nlhPcepbH7TYBL+dI/mrWRCRkrQIBZY9Q5vzb+PdxQj2P2ikBCPnrxb0TRMQpAYiRIa9lVcregR0TgATZm/G3W7cmxn5VaA6qQNkjEkNAMbPcDOpBJfYF6DMByJC/H3+3XSfC97IziATov8FD8HUcDmzZs+bETSF0Z+cEICeCE0TYOQFlHznSZoTQkwIc5PW+FqwC7NUGVagCXTvlXzNHXnXE5LsrulYAYFduX4Ts11b4LlaWlbXBWzNH2GxojzN4jgogJgENYreganyYGELsq1YCAOp9CZX5eivEwy9mltcvPvqwirBHSGKIQE6Eitg35forO5mxSo5cDJyVHIf3TRVSIxNgiUgIUO5Abel2qII4hLJnSk5M7XC2rMPGU5s2APO++11PiKBVUECEyAq5athHyvS6TO2vhOHB72/ILK+VtHnb0+EEAkeiLZGV2UpyG94cvRbgh+KcGyzenZb5l3FPbbBfzDks3zcmE9aBCIBF1FCt16meO98M6L3BEpeohIUHP65ZXvXJM2IH8oCAATZYiJWc+a7swJF/HvddnHjnuLgwE4RvY1XAAVMuwAHvHPA61cUDNnD6DUws8k/j2kJEZ8NahdjbWIBeVvJIgSISh4yJ8931SgBwpMhVwtPZKiIeaSJmeWWrgMolENh6pSKXrTjftcKU66m9ziViFSI+AWJ3tgoQADTwrtdKLvvinE2AfcAylTXyj9tn1UiE8ztbBdhUIiD2u9ez3PS5LP0QJe6UgKpgJhpOuPBv2DEBMubAmbI3H0BqDYEJcBOAy06mqpCI/xIw5zYViFx/gZc98IZyX0DtITIR+4M4n27afgX6CgB52dffsq9FawWqkipUCWLyWR7aKQEiHVwFuHbrX7batApNRO3wPOj77O3swf8zuquAneJZaEPZ14KqcOOKrYdOre8j4BTWvfZl8qD2D7ghcomuE8XXAAAAAElFTkSuQmCCksg8PmYDAAA= 101 | 102 | 103 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | Tencent is pleased to support the open source community by making xLua available. 2 | Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 3 | If you have downloaded a copy of the xLua binary from Tencent, please note that the xLua binary is licensed under the MIT License. 4 | If you have downloaded a copy of the xLua source code from Tencent, please note that xLua source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of xLua into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within xLua. 5 | A copy of the MIT License is included in this file. 6 | Other dependencies and licenses: 7 | 8 | Open Source Software Licensed under the BSD 3-Clause License: 9 | -------------------------------------------------------------------- 10 | 1. android-cmake 11 | Copyright (c) 2010-2011, Ethan Rublee 12 | Copyright (c) 2011-2014, Andrey Kamaev 13 | All rights reserved. 14 | Copyright (c) 2014, Pavel Rojtberg 15 | All rights reserved. 16 | 17 | 18 | Terms of the BSD 3-Clause License: 19 | -------------------------------------------------------------------- 20 | 21 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 22 | ?Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 23 | ?Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 24 | ?Neither the name of [copyright holder] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | Open Source Software Licensed Under the MIT License: 28 | -------------------------------------------------------------------- 29 | 1. Lua 5.1.5 & 5.3.3 & 5.3.4 30 | Copyright (C) 1994-2016 Lua.org, PUC-Rio. 31 | 32 | 2. LuaJIT 2.1.0beta2 33 | Copyright (C) 2005-2016 Mike Pall. All rights reserved. 34 | 35 | 3. luasocket 3.0-rc1 36 | Copyright ? 1999-2013 Diego Nehab. All rights reserved. 37 | 38 | 4. Cecil 0.9.6 39 | Copyright (c) 2008 - 2015 Jb Evain 40 | Copyright (c) 2008 - 2011 Novell, Inc. 41 | 42 | Terms of the MIT License: 43 | -------------------------------------------------------------------- 44 | 45 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 46 | 47 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 48 | 49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_progresstimertest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = false, 3 | _id = "ProgressTimerTest", 4 | _type = "ProgressTimerTest", 5 | height = "$fill", 6 | ignoreAnchor = 0, 7 | popOnBack = 1, 8 | width = "$fill", 9 | _children = { { 10 | _id = "progressTimer1", 11 | _type = "cc.ProgressTimer", 12 | barType = 1, 13 | height = 150, 14 | ignoreAnchor = 1, 15 | percentage = 0, 16 | reverseDirection = 1, 17 | scaleX = "$minScale", 18 | scaleY = "$minScale", 19 | width = 108, 20 | x = 60, 21 | y = 680, 22 | _sprite = { 23 | _id = "progressTimer1_sprite", 24 | _lock = 0, 25 | _type = "cc.Sprite", 26 | file = "gk/res/texture/icon_cocos.png", 27 | flippedX = 1, 28 | ignoreAnchor = 1, 29 | blendFunc = { 30 | dst = 771, 31 | src = 1}}, 32 | anchor = { 33 | x = 0, 34 | y = 1}, 35 | barChangeRate = { 36 | x = 1, 37 | y = 1}, 38 | midpoint = { 39 | x = 0.5, 40 | y = 0.5}, 41 | scaleXY = { 42 | x = "$scaleX", 43 | y = "$scaleY"}}, 44 | { 45 | _fold = false, 46 | _id = "progressTimer2", 47 | _type = "cc.ProgressTimer", 48 | barType = 0, 49 | height = 150, 50 | ignoreAnchor = 1, 51 | percentage = 0, 52 | reverseDirection = 1, 53 | scaleX = "$minScale", 54 | scaleY = "$minScale", 55 | width = 108, 56 | x = 300, 57 | y = 680, 58 | _sprite = { 59 | _id = "progressTimer2_sprite", 60 | _lock = 0, 61 | _type = "cc.Sprite", 62 | file = "gk/res/texture/icon_cocos.png", 63 | flippedX = 1, 64 | flippedY = 1, 65 | ignoreAnchor = 1, 66 | blendFunc = { 67 | dst = 771, 68 | src = 1}}, 69 | anchor = { 70 | x = 0, 71 | y = 1}, 72 | barChangeRate = { 73 | x = 0, 74 | y = 1}, 75 | midpoint = { 76 | x = 0.5, 77 | y = 0.5}, 78 | scaleXY = { 79 | x = "$scaleX", 80 | y = "$scaleY"}}, 81 | { 82 | _id = "progressTimer3", 83 | _type = "cc.ProgressTimer", 84 | barType = 1, 85 | height = 150, 86 | ignoreAnchor = 1, 87 | percentage = 0, 88 | reverseDirection = 1, 89 | scaleX = "$minScale", 90 | scaleY = "$minScale", 91 | width = 108, 92 | x = 60, 93 | y = 500, 94 | _sprite = { 95 | _id = "progressTimer3_sprite", 96 | _lock = 0, 97 | _type = "cc.Sprite", 98 | file = "gk/res/texture/icon_cocos.png", 99 | flippedX = 1, 100 | ignoreAnchor = 1, 101 | blendFunc = { 102 | dst = 771, 103 | src = 1}}, 104 | anchor = { 105 | x = 0, 106 | y = 1}, 107 | barChangeRate = { 108 | x = 1, 109 | y = 0}, 110 | midpoint = { 111 | x = 0, 112 | y = 1}, 113 | scaleXY = { 114 | x = "$scaleX", 115 | y = "$scaleY"}}, 116 | { 117 | _fold = false, 118 | _id = "progressTimer4", 119 | _type = "cc.ProgressTimer", 120 | barType = 0, 121 | height = 150, 122 | ignoreAnchor = 1, 123 | percentage = 0, 124 | reverseDirection = 1, 125 | scaleX = "$minScale", 126 | scaleY = "$minScale", 127 | width = 108, 128 | x = 300, 129 | y = 500, 130 | _sprite = { 131 | _id = "progressTimer4_sprite", 132 | _lock = 0, 133 | _type = "cc.Sprite", 134 | file = "gk/res/texture/icon_cocos.png", 135 | flippedX = 1, 136 | flippedY = 1, 137 | ignoreAnchor = 1, 138 | blendFunc = { 139 | dst = 771, 140 | src = 1}}, 141 | anchor = { 142 | x = 0, 143 | y = 1}, 144 | barChangeRate = { 145 | x = 0, 146 | y = 1}, 147 | midpoint = { 148 | x = 0.1, 149 | y = 0.1}, 150 | scaleXY = { 151 | x = "$scaleX", 152 | y = "$scaleY"}}}} -------------------------------------------------------------------------------- /src/gk/test/gen/config.lua: -------------------------------------------------------------------------------- 1 | return { 2 | fontDir = "gk/test/res/font/", 3 | genDir = "gk/test/gen/", 4 | shaderDir = "", 5 | fontFiles = {}, 6 | genNodes = { 7 | APITest = { 8 | cname = "APITest", 9 | genPath = "gk/test/gen/layout/gk_test_api_apitest.lua", 10 | genSrcPath = "gk/test/api/", 11 | path = "gk/test/api/APITest"}, 12 | ButtonTest = { 13 | cname = "ButtonTest", 14 | genPath = "gk/test/gen/layout/gk_test_buttontest.lua", 15 | genSrcPath = "gk/test/", 16 | path = "gk/test/ButtonTest"}, 17 | C3DLayerTest = { 18 | cname = "C3DLayerTest", 19 | genPath = "gk/test/gen/layout/gk_test_c3dlayertest.lua", 20 | genSrcPath = "gk/test/", 21 | path = "gk/test/C3DLayerTest"}, 22 | ClippingNodeTest = { 23 | cname = "ClippingNodeTest", 24 | genPath = "gk/test/gen/layout/gk_test_clippingnodetest.lua", 25 | genSrcPath = "gk/test/", 26 | path = "gk/test/ClippingNodeTest"}, 27 | Dialog1 = { 28 | cname = "Dialog1", 29 | genPath = "gk/test/gen/layout/gk_test_dialog_dialog1.lua", 30 | genSrcPath = "gk/test/dialog/", 31 | path = "gk/test/dialog/Dialog1"}, 32 | DialogTest = { 33 | cname = "DialogTest", 34 | genPath = "gk/test/gen/layout/gk_test_dialogtest.lua", 35 | genSrcPath = "gk/test/", 36 | path = "gk/test/DialogTest"}, 37 | DrawNodeTest = { 38 | cname = "DrawNodeTest", 39 | genPath = "gk/test/gen/layout/gk_test_drawnodetest.lua", 40 | genSrcPath = "gk/test/", 41 | path = "gk/test/DrawNodeTest"}, 42 | FSMTest = { 43 | cname = "FSMTest", 44 | genPath = "gk/test/gen/layout/gk_test_fsm_fsmtest.lua", 45 | genSrcPath = "gk/test/fsm/", 46 | path = "gk/test/fsm/FSMTest"}, 47 | GameFSM = { 48 | cname = "GameFSM", 49 | genPath = "gk/test/gen/layout/gk_test_fsm_gamefsm.lua", 50 | genSrcPath = "gk/test/fsm/", 51 | path = "gk/test/fsm/GameFSM"}, 52 | LabelTest = { 53 | cname = "LabelTest", 54 | genPath = "gk/test/gen/layout/gk_test_labeltest.lua", 55 | genSrcPath = "gk/test/", 56 | path = "gk/test/LabelTest"}, 57 | NodeTest = { 58 | cname = "NodeTest", 59 | genPath = "gk/test/gen/layout/gk_test_nodetest.lua", 60 | genSrcPath = "gk/test/", 61 | path = "gk/test/NodeTest"}, 62 | ParticleSystemTest = { 63 | cname = "ParticleSystemTest", 64 | genPath = "gk/test/gen/layout/gk_test_particlesystemtest.lua", 65 | genSrcPath = "gk/test/", 66 | path = "gk/test/ParticleSystemTest"}, 67 | Path = { 68 | cname = "Path", 69 | genPath = "gk/test/gen/layout/gk_test_path.lua", 70 | genSrcPath = "gk/test/", 71 | path = "gk/test/Path"}, 72 | PopupBg = { 73 | cname = "PopupBg", 74 | genPath = "gk/test/gen/layout/gk_test_widget_popupbg.lua", 75 | genSrcPath = "gk/test/widget/", 76 | isWidget = true, 77 | path = "gk/test/widget/PopupBg"}, 78 | ProgressTimerTest = { 79 | cname = "ProgressTimerTest", 80 | genPath = "gk/test/gen/layout/gk_test_progresstimertest.lua", 81 | genSrcPath = "gk/test/", 82 | path = "gk/test/ProgressTimerTest"}, 83 | ShaderTest = { 84 | cname = "ShaderTest", 85 | genPath = "gk/test/gen/layout/gk_test_shadertest.lua", 86 | genSrcPath = "gk/test/", 87 | path = "gk/test/ShaderTest"}, 88 | SolarSystem = { 89 | cname = "SolarSystem", 90 | genPath = "gk/test/gen/layout/gk_test_solarsystem.lua", 91 | genSrcPath = "gk/test/", 92 | path = "gk/test/SolarSystem"}, 93 | TableCell1 = { 94 | cname = "TableCell1", 95 | genPath = "gk/test/gen/layout/gk_test_cell_tablecell1.lua", 96 | genSrcPath = "gk/test/cell/", 97 | path = "gk/test/cell/TableCell1"}, 98 | TableViewTest = { 99 | cname = "TableViewTest", 100 | genPath = "gk/test/gen/layout/gk_test_tableviewtest.lua", 101 | genSrcPath = "gk/test/", 102 | path = "gk/test/TableViewTest"}, 103 | TextButton = { 104 | cname = "TextButton", 105 | genPath = "gk/test/gen/layout/gk_test_widget_textbutton.lua", 106 | genSrcPath = "gk/test/widget/", 107 | isWidget = true, 108 | path = "gk/test/widget/TextButton"}}} -------------------------------------------------------------------------------- /src/gk/fsm/FSMEditor.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 19/12/2017 5 | -- Time: 18:06 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local FSMEditor = class("FSMEditor", gk.Layer) 10 | 11 | function FSMEditor:ctor(...) 12 | FSMEditor.super.ctor(self, ...) 13 | if gk.mode == gk.MODE_EDIT then 14 | self:scheduleUpdate(function(delta) 15 | self:update(delta) 16 | end) 17 | end 18 | end 19 | 20 | function FSMEditor:onEnter() 21 | FSMEditor.super.onEnter(self) 22 | self:update(0) 23 | if gk.mode == gk.MODE_RELEASE_CURRENT then 24 | if self.__path then 25 | self.fsm = gk.injector:inflateFSM(self.__path) 26 | self:updateDisplay() 27 | for k, v in pairs(self.trans) do 28 | v.button1:onClicked(function() 29 | self.fsm[v.action]() 30 | self:updateDisplay() 31 | end) 32 | end 33 | end 34 | end 35 | end 36 | 37 | function FSMEditor:updateDisplay() 38 | for k, v in pairs(self.states) do 39 | v:setSelected(self.fsm:is(k)) 40 | end 41 | for k, v in pairs(self.trans) do 42 | if v.from == self.fsm:getState() then 43 | local to = self.fsm:can(v.action) 44 | if to and to == v.to then 45 | v:setTransabled(true) 46 | else 47 | v:setTransabled(false) 48 | end 49 | else 50 | v:setTransabled(false) 51 | end 52 | end 53 | end 54 | 55 | function FSMEditor:update(delta) 56 | self.states = {} 57 | self.trans = {} 58 | local children = self:getChildren() 59 | for i = 1, #children do 60 | local child = children[i] 61 | if gk.util:instanceof(child, "FSMNode") then 62 | self.states[child.state] = child 63 | elseif gk.util:instanceof(child, "FSMTransNode") then 64 | table.insert(self.trans, child) 65 | end 66 | end 67 | for k, tran in pairs(self.trans) do 68 | local from = self.states[tran.from] 69 | local to = self.states[tran.to] 70 | if from and to then 71 | local p1, p2 = self:getLine(from, to) 72 | p1 = from:convertToWorldSpace(p1) 73 | tran.quadBezierNode1:setOrigin(tran.quadBezierNode1:convertToNodeSpace(p1)) 74 | p2 = to:convertToWorldSpace(p2) 75 | tran.quadBezierNode1:setMovablePoints(tran.quadBezierNode1:convertToNodeSpace(p2), 3) 76 | end 77 | end 78 | end 79 | 80 | function FSMEditor:getLine(from, to) 81 | local p1 = cc.p(from:getPosition()) 82 | local p2 = cc.p(to:getPosition()) 83 | local dt = cc.pSub(p2, p1) 84 | local idx1, idx2 = 1, 1 85 | -- 2 86 | --1 3 87 | -- 4 88 | if dt.x > 0 then 89 | if dt.y > 0 then 90 | -- B 91 | --A 92 | if math.abs(dt.x) > math.abs(dt.y) then 93 | idx1, idx2 = 3, 1 94 | else 95 | idx1, idx2 = 3, 4 96 | end 97 | else 98 | --A 99 | -- B 100 | if math.abs(dt.x) > math.abs(dt.y) then 101 | idx1, idx2 = 3, 1 102 | else 103 | idx1, idx2 = 3, 2 104 | end 105 | end 106 | else 107 | if dt.y > 0 then 108 | --B 109 | -- A 110 | if math.abs(dt.x) > math.abs(dt.y) then 111 | idx1, idx2 = 1, 3 112 | else 113 | idx1, idx2 = 1, 4 114 | end 115 | else 116 | -- A 117 | --B 118 | if math.abs(dt.x) > math.abs(dt.y) then 119 | idx1, idx2 = 1, 3 120 | else 121 | idx1, idx2 = 4, 3 122 | end 123 | end 124 | end 125 | 126 | local size = from:getContentSize() 127 | p1 = cc.p(size.width / 2, size.height / 2) 128 | p2 = cc.p(size.width / 2, size.height / 2) 129 | if math.mod(idx1, 2) == 1 then 130 | p1.x = p1.x + (idx1 - 2) * size.width / 2 131 | else 132 | p1.y = p1.y + (3 - idx1) * size.height / 2 133 | end 134 | if math.mod(idx2, 2) == 1 then 135 | p2.x = p2.x + (idx2 - 2) * size.width / 2 136 | else 137 | p2.y = p2.y + (3 - idx2) * size.height / 2 138 | end 139 | return p1, p2 140 | end 141 | 142 | return FSMEditor -------------------------------------------------------------------------------- /src/gk/test/C3DLayerTest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 23/11/2017 5 | -- Time: 19:10 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local C3DLayerTest = class("C3DLayerTest", gk.Layer) 10 | 11 | function C3DLayerTest:ctor() 12 | C3DLayerTest.super.ctor(self) 13 | -- cc.Director:getInstance():setDepthTest(true) 14 | end 15 | 16 | function C3DLayerTest:createSkyBox() 17 | --create and set our custom shader 18 | local shader = cc.GLProgram:createWithFilenames("3d/cube_map.vert", "3d/cube_map.frag") 19 | local state = cc.GLProgramState:create(shader) 20 | --create the second texture for cylinder 21 | local textureCube = cc.TextureCube:create("3d/skybox/left.jpg", "3d/skybox/right.jpg", 22 | "3d/skybox/top.jpg", "3d/skybox/bottom.jpg", 23 | "3d/skybox/front.jpg", "3d/skybox/back.jpg") 24 | --set texture parameters 25 | local tRepeatParams = { magFilter = gl.LINEAR, minFilter = gl.LINEAR, wrapS = gl.MIRRORED_REPEAT, wrapT = gl.MIRRORED_REPEAT } 26 | textureCube:setTexParameters(tRepeatParams) 27 | --pass the texture sampler to our custom shader 28 | state:setUniformTexture("u_cubeTex", textureCube) 29 | 30 | --add skybox 31 | local skyBox = cc.Skybox:create() 32 | skyBox:setCameraMask(cc.CameraFlag.USER1) 33 | skyBox:setTexture(textureCube) 34 | self:addChild(skyBox) 35 | 36 | local winSize = gk.display:winSize() 37 | local zeye = cc.Director:getInstance():getZEye() 38 | local camera = cc.Camera:createPerspective(60, winSize.width / winSize.height, 10, zeye + winSize.height / 2) 39 | local eye = cc.vec3(0, 0, 50) 40 | -- local center = cc.vec3(winSize.width / 2, winSize.height / 2, 0.0) 41 | -- local up = cc.vec3(0.0, 1.0, 0.0) 42 | camera:setPosition3D(eye) 43 | -- camera:lookAt(center, up) 44 | camera:setCameraFlag(cc.CameraFlag.USER1) 45 | self:addChild(camera) 46 | end 47 | 48 | function C3DLayerTest:onEnter() 49 | C3DLayerTest.super.onEnter(self) 50 | 51 | self:createSkyBox() 52 | self.label1:setPositionZ(-244) 53 | 54 | local scene = cc.Director:getInstance():getRunningScene() 55 | local defaultCamera = scene:getDefaultCamera() 56 | 57 | local winSize = gk.display:winSize() 58 | local zeye = cc.Director:getInstance():getZEye() 59 | local camera = cc.Camera:createPerspective(60, winSize.width / winSize.height, 10, zeye + winSize.height / 2) 60 | local eye = cc.vec3(winSize.width / 2, winSize.height / 2.0, zeye) 61 | local center = cc.vec3(winSize.width / 2, winSize.height / 2, 0.0) 62 | local up = cc.vec3(0.0, 1.0, 0.0) 63 | camera:setPosition3D(eye) 64 | dump(eye) 65 | dump(center) 66 | gk.log("maxZ = %f", eye.z - 10) 67 | gk.log("minZ = %f", eye.z - (zeye + winSize.height / 2)) 68 | camera:lookAt(center, up) 69 | 70 | camera:setCameraFlag(cc.CameraFlag.USER2) 71 | -- camera:lookAt(cc.vec3(0.0, 0.0, 0.0), cc.vec3(0.0, 1.0, 0.0)) 72 | self:addChild(camera) 73 | camera:setDepth(1) 74 | 75 | local size = self:getContentSize() 76 | local sprite = cc.Sprite3D:create("3d/girl.c3b") 77 | sprite:setRotation3D({ x = 0, y = 0, z = 0 }) 78 | sprite:setPosition3D(cc.vec3(size.width * 3 / 4, size.height / 2, 10)) 79 | -- self:addChild(sprite) 80 | self:addChild(sprite) 81 | sprite:setCameraMask(cc.CameraFlag.USER2) 82 | 83 | local animation = cc.Animation3D:create("3d/girl.c3b", "Take 001") 84 | if nil ~= animation then 85 | local animate = cc.Animate3D:create(animation) 86 | sprite:runAction(cc.RepeatForever:create(animate)) 87 | end 88 | 89 | local sprite = cc.Sprite3D:create("3d/orc.c3b") 90 | sprite:setScale(3) 91 | sprite:setRotation3D({ x = 0, y = 180, z = 0 }) 92 | sprite:setPosition3D(cc.vec3(size.width / 2, 50, 10)) 93 | self:addChild(sprite) 94 | sprite:setCameraMask(cc.CameraFlag.USER2) 95 | local animation = cc.Animation3D:create("3d/orc.c3b") 96 | local animate = cc.Animate3D:create(animation) 97 | local repeatAction = cc.RepeatForever:create(animate) 98 | sprite:runAction(repeatAction) 99 | 100 | local sprite = cc.Sprite3D:create("3d/boss.c3b") 101 | sprite:setScale(3) 102 | sprite:setRotation3D({ x = 0, y = 180, z = 0 }) 103 | sprite:setPosition3D(cc.vec3(size.width / 2, size.height - 50, 10)) 104 | self:addChild(sprite) 105 | sprite:setCameraMask(cc.CameraFlag.USER2) 106 | end 107 | 108 | return C3DLayerTest -------------------------------------------------------------------------------- /src/gk/test/cell/TableCell1.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 17/2/7 5 | -- Time: 上午9:29 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local TableCell1 = class("TableCell1", gk.TableViewCell) 10 | 11 | local popMaxWidth = 300 12 | local popMinHeight = 80 13 | local popVerticalMargin = 10 14 | 15 | local textLeftMargin = 26 16 | local textRightMargin = 15 17 | local textVerticalMargin = 20 18 | 19 | -- must have a __cname and ctor to be injected 20 | function TableCell1:ctor() 21 | TableCell1.super.ctor(self) 22 | 23 | if gk.mode ~= gk.MODE_RELEASE then 24 | -- self:setData({ type = "Member", content = "Hello" }) 25 | -- self:setData({ type = "Member", content = "If schools are mandated to be gun free zones, violence and danger are given an open invitation to enter. Almost all school shootings are in gun free zones. Cowards will only go where there is no deterrent!" }) 26 | -- self:setData({ type = "Me", content = "Hello" }) 27 | self:setData({ type = "Me", content = "I say this as a former Secretary of State and as an American: the Russians are still coming. Our intelligence professionals are imploring Trump to act. Will he continue to ignore & surrender, or protect our country?" }) 28 | -- self:setData({ type = "Time", content = "20:00" }) 29 | -- self:setData({ type = "Time", content = "Yesterday 18:45" }) 30 | end 31 | end 32 | 33 | function TableCell1:setData(dt) 34 | if dt.type == "Member" then 35 | self.Time:hide() 36 | self.Me:hide() 37 | self.Member:show() 38 | self.label_left:setDimensions(0, 0) 39 | self.label_left:setString(dt.content) 40 | local size = self.label_left:getContentSize() 41 | if size.width > popMaxWidth - textLeftMargin - textRightMargin then 42 | self.label_left:setDimensions(popMaxWidth - textLeftMargin - textRightMargin, 0) 43 | size = self.label_left:getContentSize() 44 | end 45 | local popWidth = math.min(popMaxWidth, size.width + textLeftMargin + textRightMargin) 46 | local popHeight = math.max(popMinHeight, size.height + textVerticalMargin * 2) 47 | self.pop_left:setContentSize(cc.size(popWidth, popHeight)) 48 | self.cellHeight = popVerticalMargin * 2 + popHeight 49 | self.Member:setContentSize(cc.size(self:getContentSize().width, self.cellHeight)) 50 | self.avatar_left:setPositionY(self.cellHeight - popVerticalMargin) 51 | self.pop_left:setPositionY(self.cellHeight - popVerticalMargin) 52 | self.label_left:setPositionY(self.pop_left:getContentSize().height / 2) 53 | elseif dt.type == "Me" then 54 | self.Member:hide() 55 | self.Time:hide() 56 | self.Me:show() 57 | self.label_right:setDimensions(0, 0) 58 | self.label_right:setString(dt.content) 59 | local size = self.label_right:getContentSize() 60 | if size.width > popMaxWidth - textLeftMargin - textRightMargin then 61 | self.label_right:setDimensions(popMaxWidth - textLeftMargin - textRightMargin, 0) 62 | size = self.label_right:getContentSize() 63 | end 64 | local popWidth = math.min(popMaxWidth, size.width + textLeftMargin + textRightMargin) 65 | local popHeight = math.max(popMinHeight, size.height + textVerticalMargin * 2) 66 | self.pop_right:setContentSize(cc.size(popWidth, popHeight)) 67 | self.cellHeight = popVerticalMargin * 2 + popHeight 68 | self.Me:setContentSize(cc.size(self:getContentSize().width, self.cellHeight)) 69 | self.avatar_right:setPositionY(self.cellHeight - popVerticalMargin) 70 | self.pop_right:setPositionY(self.cellHeight - popVerticalMargin) 71 | self.label_right:setPositionX(self.pop_right:getContentSize().width - textLeftMargin) 72 | self.label_right:setPositionY(self.pop_right:getContentSize().height / 2) 73 | elseif dt.type == "Time" then 74 | self.Member:hide() 75 | self.Me:hide() 76 | self.Time:show() 77 | self.desc:setString(dt.content) 78 | local size = self.desc:getContentSize() 79 | local margin = 18 80 | size.width = size.width + margin 81 | size.height = size.height + margin 82 | self.bg_time:setContentSize(size) 83 | self.desc:setPosition(size.width / 2, size.height / 2) 84 | self.cellHeight = self.Time:getContentSize().height 85 | end 86 | 87 | self:setContentSize(cc.size(self:getContentSize().width, self.cellHeight)) 88 | end 89 | 90 | return TableCell1 -------------------------------------------------------------------------------- /src/gk/node/SpriteButton.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 5/18/17 5 | -- Time: 15:17 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local Button = import(".Button") 10 | local SpriteButton = class("SpriteButton", Button) 11 | 12 | gk.SELECT_MODE_REPLACE = 0 -- replace image on state changed 13 | gk.SELECT_MODE_OVERLAY = 1 -- add image on normalSprite on state changed 14 | 15 | function SpriteButton:ctor(normalSprite, selectedSprite, disabledSprite, capInsets) 16 | self.normalSprite = normalSprite 17 | self.selectedSprite = selectedSprite and selectedSprite or normalSprite 18 | self.disabledSprite = disabledSprite and disabledSprite or normalSprite 19 | self.capInsets = capInsets 20 | self.selectMode = gk.SELECT_MODE_REPLACE 21 | 22 | self.__setContentSize = self.setContentSize 23 | self.setContentSize = function(_self, ...) 24 | self:_setContentSize(...) 25 | end 26 | local content = gk.create_sprite(normalSprite) 27 | SpriteButton.super.ctor(self, content) 28 | self.addChild = self.__addChild 29 | end 30 | 31 | function SpriteButton:setSelectMode(mode) 32 | if self.selectMode ~= mode then 33 | self.selectMode = mode 34 | if mode == gk.SELECT_MODE_OVERLAY then 35 | self.overlay = gk.create_sprite(self.normalSprite) 36 | self:addChild(self.overlay) 37 | self.overlay:setTag(gk.util.tags.buttonOverlayTag) 38 | else 39 | if self.overlay then 40 | self.overlay:removeFromParent() 41 | self.overlay = nil 42 | end 43 | end 44 | self:updateSpriteFrame() 45 | end 46 | end 47 | 48 | function SpriteButton:getSelectMode() 49 | return self.selectMode 50 | end 51 | 52 | function SpriteButton:setNormalSprite(normalSprite) 53 | self.normalSprite = normalSprite 54 | self:updateSpriteFrame() 55 | end 56 | 57 | function SpriteButton:setSelectedSprite(selectedSprite) 58 | self.selectedSprite = selectedSprite 59 | self:updateSpriteFrame() 60 | end 61 | 62 | function SpriteButton:setDisabledSprite(disabledSprite) 63 | self.disabledSprite = disabledSprite 64 | self:updateSpriteFrame() 65 | end 66 | 67 | function SpriteButton:_setContentSize(size) 68 | self:__setContentSize(size) 69 | if self.capInsets and self.capInsets.width ~= 0 and self.capInsets.height ~= 0 then 70 | self.contentNode:setContentSize(size) 71 | end 72 | local anchorPoint = self.contentNode:getAnchorPoint() 73 | self.contentNode:setPosition(cc.p(size.width * anchorPoint.x, size.height * anchorPoint.y)) 74 | if self.overlay then 75 | if self.capInsets and self.capInsets.width ~= 0 and self.capInsets.height ~= 0 then 76 | self.overlay:setContentSize(size) 77 | end 78 | self.overlay:setPosition(cc.p(size.width * anchorPoint.x, size.height * anchorPoint.y)) 79 | end 80 | end 81 | 82 | function SpriteButton:updateSpriteFrame() 83 | local pre = self:getContentSize() 84 | local spriteFrameName = self.enabled and (self.selected and self.selectedSprite or self.normalSprite) or self.disabledSprite 85 | if self.selectMode == gk.SELECT_MODE_REPLACE then 86 | self.contentNode:setSpriteFrame(gk.create_sprite_frame(spriteFrameName)) 87 | elseif self.selectMode == gk.SELECT_MODE_OVERLAY and self.overlay then 88 | if self.enabled and not self.selected then 89 | self.overlay:hide() 90 | self.contentNode:setSpriteFrame(gk.create_sprite_frame(spriteFrameName)) 91 | else 92 | self.overlay:show() 93 | self.overlay:setSpriteFrame(gk.create_sprite_frame(spriteFrameName)) 94 | end 95 | end 96 | self:setContentSize(pre) 97 | end 98 | 99 | function SpriteButton:getCapInsets() 100 | return self.capInsets 101 | end 102 | 103 | function SpriteButton:setCapInsets(capInsets) 104 | self.capInsets = capInsets 105 | if self.capInsets and capInsets.width ~= 0 and capInsets.height ~= 0 then 106 | self.contentNode:setCenterRect(capInsets) 107 | if self.overlay then 108 | self.overlay:setCenterRect(capInsets) 109 | end 110 | end 111 | end 112 | 113 | function SpriteButton:setSelected(selected) 114 | if self.enabled and self.selected ~= selected then 115 | SpriteButton.super.setSelected(self, selected) 116 | self:updateSpriteFrame() 117 | end 118 | end 119 | 120 | function SpriteButton:setEnabled(enabled) 121 | if self.enabled ~= enabled then 122 | SpriteButton.super.setEnabled(self, enabled) 123 | self:updateSpriteFrame() 124 | end 125 | end 126 | 127 | return SpriteButton -------------------------------------------------------------------------------- /src/gk/node/Dialog.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/7/7 5 | -- Time: 下午5:21 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | --- Pop up dialog: default pop self when click Android back(keyboard Esc) 10 | local Layer = import(".Layer") 11 | local Dialog = class("Dialog", Layer) 12 | 13 | function Dialog:ctor() 14 | -- set default value before ctor, inflate from __info may change it 15 | self.popOnTouchOutsideBg = false 16 | self.popOnTouchInsideBg = false 17 | Dialog.super.ctor(self) 18 | end 19 | 20 | function Dialog:setPopOnTouchInsideBg(var) 21 | self.popOnTouchInsideBg = var 22 | end 23 | 24 | function Dialog:isPopOnTouchInsideBg() 25 | return self.popOnTouchInsideBg 26 | end 27 | 28 | function Dialog:setPopOnTouchOutsideBg(var) 29 | self.popOnTouchOutsideBg = var 30 | end 31 | 32 | function Dialog:isPopOnTouchOutsideBg() 33 | return self.popOnTouchOutsideBg 34 | end 35 | 36 | function Dialog:addMaskLayer(opacity) 37 | local opa = opacity or (Dialog.MASK_OPACITY and Dialog.MASK_OPACITY or 200) 38 | local layerColor = cc.LayerColor:create(cc.c4b(0, 0, 0, opa)) 39 | self:addChild(layerColor, -1) 40 | self.maskLayer = layerColor 41 | if gk.display:iPhoneX() then 42 | local winSize = gk.display:winSize() 43 | local accWinSize = gk.display:accuWinSize() 44 | layerColor:setContentSize(accWinSize) 45 | layerColor:setPositionX(winSize.width / 2 - accWinSize.width / 2) 46 | end 47 | end 48 | 49 | function Dialog:animateOut(callback) 50 | if gk.mode ~= gk.MODE_EDIT then 51 | if self.dialogBg then 52 | local scale = self.dialogBg:getScale() 53 | self.dialogBg:setScale(0) 54 | self.dialogBg:runAction(cc.Sequence:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2, scale)), cc.CallFunc:create(function() 55 | if callback then 56 | callback() 57 | end 58 | end))) 59 | end 60 | if self.maskLayer then 61 | local opacity = self.maskLayer:getOpacity() 62 | self.maskLayer:setOpacity(0) 63 | self.maskLayer:runAction(cc.Sequence:create(cc.FadeTo:create(0.15, opacity), cc.CallFunc:create(function() 64 | if callback then 65 | callback() 66 | end 67 | end))) 68 | end 69 | else 70 | if callback then 71 | callback() 72 | end 73 | end 74 | end 75 | 76 | function Dialog:onTouchBegan(touch, event) 77 | if self.popOnTouchOutsideBg and self.popOnTouchInsideBg then 78 | gk.log("[%s]: popOnTouch", self.__cname) 79 | self:runAction(cc.CallFunc:create(function() 80 | self:pop() 81 | end)) 82 | return true 83 | end 84 | if self.dialogBg then 85 | local location = touch:getLocation() 86 | local touchBeginPoint = { x = location.x, y = location.y } 87 | local s = self.dialogBg:getContentSize() 88 | local rect = { x = 0, y = 0, width = s.width, height = s.height } 89 | local touchP = self.dialogBg:convertToNodeSpace(touchBeginPoint) 90 | if not cc.rectContainsPoint(rect, touchP) and gk.mode ~= gk.MODE_EDIT then 91 | if self.popOnTouchOutsideBg then 92 | gk.log("[%s]: popOnTouchOutsideBg", self.__cname) 93 | self:runAction(cc.CallFunc:create(function() 94 | self:pop() 95 | end)) 96 | return true 97 | end 98 | else 99 | if self.popOnTouchInsideBg then 100 | gk.log("[%s]: popOnTouchInsideBg", self.__cname) 101 | self:runAction(cc.CallFunc:create(function() 102 | self:pop() 103 | end)) 104 | return true 105 | end 106 | end 107 | end 108 | 109 | return self.swallowTouches 110 | end 111 | 112 | function Dialog:pop(...) 113 | if self.parent then 114 | gk.log("[%s]: popDialog --> %s", self.parent.__cname, self.__cname) 115 | table.removebyvalue(self.parent.dialogsStack, self) 116 | self:retain() 117 | if self.onPopCallback then 118 | self.onPopCallback(...) 119 | end 120 | self:release() 121 | self:removeFromParent() 122 | gk.SceneManager:printSceneStack() 123 | else 124 | gk.log("[%s]: pop error, parent is nil", self.__cname) 125 | end 126 | end 127 | 128 | function Dialog:onKeyBack() 129 | if self.popOnBack then 130 | gk.log("[%s]: pop onKeyBack", self.__cname) 131 | if self.onKeyBackCallback then 132 | self.onKeyBackCallback() 133 | else 134 | self:pop() 135 | end 136 | return true 137 | else 138 | gk.log("[%s]: pop onKeyBack is disable", self.__cname) 139 | return false 140 | end 141 | end 142 | 143 | function Dialog:show() 144 | return gk.SceneManager:showDialogNode(self) 145 | end 146 | 147 | return Dialog -------------------------------------------------------------------------------- /src/gk/hotUpdate.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka 4 | -- Date: 7/31/17 5 | -- Time: 14:04 6 | -- To change this template use File | Settings | File Templates. 7 | -- 8 | 9 | local hotUpdate = {} 10 | 11 | -- this file cannot be hot updated 12 | -- must init this in main.lua before require any other modules 13 | -- use for instance run on mac, or hot update on other platform 14 | function hotUpdate:init(originVersion) 15 | local DOC_ROOT = cc.FileUtils:getInstance():getWritablePath() 16 | 17 | local curVersion = cc.UserDefault:getInstance():getStringForKey("gk_currentVersion") 18 | if curVersion == "" then 19 | curVersion = originVersion 20 | end 21 | local ret = self:compareVersion(curVersion, originVersion) 22 | if ret == 1 then 23 | -- current is bigger than origin, use hot update 24 | print(string.format("curVersion = %s is big than originVersion = %s, use hot update", curVersion, originVersion)) 25 | if not cc.FileUtils:getInstance():isDirectoryExist(DOC_ROOT .. curVersion .. "/") then 26 | print(string.format("hot update dir not exist = %s, need redownload hotupdate", DOC_ROOT .. curVersion .. "/")) 27 | cc.UserDefault:getInstance():setStringForKey("gk_currentVersion", originVersion) 28 | cc.UserDefault:getInstance():flush() 29 | else 30 | -- hot update search path 31 | cc.FileUtils:getInstance():setSearchPaths({}) 32 | cc.FileUtils:getInstance():addSearchPath(DOC_ROOT .. curVersion .. "/src/") 33 | cc.FileUtils:getInstance():addSearchPath(DOC_ROOT .. curVersion .. "/res/") 34 | cc.FileUtils:getInstance():addSearchPath("src/") 35 | cc.FileUtils:getInstance():addSearchPath("res/") 36 | end 37 | elseif ret == -1 then 38 | -- big version, remove old files 39 | print(string.format("big version = %s, remove old version = %s", originVersion, curVersion)) 40 | self:removeOldVersion(curVersion) 41 | cc.UserDefault:getInstance():setStringForKey("gk_currentVersion", originVersion) 42 | cc.UserDefault:getInstance():flush() 43 | else 44 | -- equal, do nothing 45 | print(string.format("same version = %s, no hotupdate", curVersion)) 46 | cc.UserDefault:getInstance():setStringForKey("gk_currentVersion", curVersion) 47 | cc.UserDefault:getInstance():flush() 48 | end 49 | end 50 | 51 | -- return 1:version1 > version2 52 | -- return 0:version1 == version2 53 | -- return -1:version1 < version2 54 | function hotUpdate:compareVersion(version1, version2) 55 | if version1 == version2 then 56 | return 0 57 | end 58 | local function split(input, delimiter) 59 | input = tostring(input) 60 | delimiter = tostring(delimiter) 61 | if (delimiter == '') then return false end 62 | local pos, arr = 0, {} 63 | -- for each divider found 64 | for st, sp in function() return string.find(input, delimiter, pos, true) end do 65 | table.insert(arr, string.sub(input, pos, st - 1)) 66 | pos = sp + 1 67 | end 68 | table.insert(arr, string.sub(input, pos)) 69 | return arr 70 | end 71 | 72 | local v1 = split(version1, ".") 73 | local v2 = split(version2, ".") 74 | local len = math.min(#v1, #v2) 75 | for i = 1, len do 76 | if tonumber(v1[i]) > tonumber(v2[i]) then 77 | return 1 78 | elseif tonumber(v1[i]) < tonumber(v2[i]) then 79 | return -1 80 | end 81 | end 82 | if #v1 == #v2 then 83 | return 0 84 | else 85 | return #v1 > #v2 and 1 or -1 86 | end 87 | end 88 | 89 | function hotUpdate:removeOldVersion(oldVersion) 90 | if oldVersion ~= "" then 91 | local DOC_ROOT = cc.FileUtils:getInstance():getWritablePath() 92 | local dir = DOC_ROOT .. oldVersion .. "/" 93 | print("removeOldVersion = " .. dir) 94 | cc.FileUtils:getInstance():removeDirectory(dir) 95 | end 96 | end 97 | 98 | function hotUpdate:updateToNewVersion(newVersion) 99 | print(string.format("update to newVersion = %s", newVersion)) 100 | cc.UserDefault:getInstance():setStringForKey("gk_currentVersion", newVersion) 101 | cc.UserDefault:getInstance():flush() 102 | local DOC_ROOT = cc.FileUtils:getInstance():getWritablePath() 103 | cc.FileUtils:getInstance():setSearchPaths({}) 104 | cc.FileUtils:getInstance():addSearchPath(DOC_ROOT .. newVersion .. "/src/") 105 | cc.FileUtils:getInstance():addSearchPath(DOC_ROOT .. newVersion .. "/res/") 106 | cc.FileUtils:getInstance():addSearchPath("src/") 107 | cc.FileUtils:getInstance():addSearchPath("res/") 108 | end 109 | 110 | function hotUpdate:reset() 111 | print(string.format("hotUpdate reset")) 112 | cc.UserDefault:getInstance():setStringForKey("gk_currentVersion", "") 113 | cc.UserDefault:getInstance():flush() 114 | cc.FileUtils:getInstance():setSearchPaths({}) 115 | cc.FileUtils:getInstance():addSearchPath("src/") 116 | cc.FileUtils:getInstance():addSearchPath("res/") 117 | end 118 | 119 | return hotUpdate -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_drawnodetest.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = true, 3 | _id = "drawNodeTest1", 4 | _type = "DrawNodeTest", 5 | height = "$fill", 6 | width = "$fill", 7 | _children = { { 8 | _id = "drawNodeCircle1", 9 | _type = "DrawNodeCircle", 10 | angle = 0, 11 | drawLineToCenter = 1, 12 | radius = 80, 13 | scaleX = "$minScale", 14 | scaleY = "$minScale", 15 | solid = 1, 16 | x = 160, 17 | y = 620, 18 | scaleXY = { 19 | x = "$scaleX", 20 | y = "$scaleY"}}, 21 | { 22 | _id = "cubicBezierNode1", 23 | _type = "CubicBezierNode", 24 | curvesNum = 2, 25 | lineWidth = 1, 26 | scaleX = "$minScale", 27 | scaleY = "$minScale", 28 | x = 300, 29 | y = 620, 30 | scaleXY = { 31 | x = "$scaleX", 32 | y = "$scaleY"}, 33 | destination = { { 34 | c1 = { 35 | x = 0, 36 | y = -44}, 37 | c2 = { 38 | x = 36, 39 | y = -80}, 40 | dst = { 41 | x = 80, 42 | y = -80}}, 43 | { 44 | c1 = { 45 | x = 124, 46 | y = -80}, 47 | c2 = { 48 | x = 160, 49 | y = -44}, 50 | dst = { 51 | x = 160, 52 | y = 0}}}}, 53 | { 54 | _id = "drawPolygon1", 55 | _type = "DrawPolygon", 56 | borderWidth = 1, 57 | scaleX = "$minScale", 58 | scaleY = "$minScale", 59 | x = 517, 60 | y = 620, 61 | c4f = { 62 | a = 0.5, 63 | b = 0, 64 | g = 1, 65 | r = 0}, 66 | fillColor = { 67 | a = 0.2, 68 | b = 0.5, 69 | g = 0, 70 | r = 0}, 71 | scaleXY = { 72 | x = "$scaleX", 73 | y = "$scaleY"}}, 74 | { 75 | _id = "drawCardinalSpline1", 76 | _type = "DrawCardinalSpline", 77 | scaleX = "$minScale", 78 | scaleY = "$minScale", 79 | segments = 100, 80 | tension = 0.2, 81 | x = 706, 82 | y = 620, 83 | scaleXY = { 84 | x = "$scaleX", 85 | y = "$scaleY"}}, 86 | { 87 | _id = "drawPoint1", 88 | _type = "DrawPoint", 89 | dot = 1, 90 | pointSize = 40, 91 | scaleX = "$minScale", 92 | scaleY = "$minScale", 93 | x = 1070, 94 | y = 608, 95 | scaleXY = { 96 | x = "$scaleX", 97 | y = "$scaleY"}}, 98 | { 99 | _id = "drawNodeCircle2", 100 | _type = "DrawNodeCircle", 101 | angle = 0, 102 | drawLineToCenter = 0, 103 | radius = 80, 104 | scaleX = "$minScale", 105 | scaleY = "$minScale", 106 | solid = 0, 107 | x = 160, 108 | y = 430, 109 | c4f = { 110 | a = 0.2, 111 | b = 0, 112 | g = 1, 113 | r = 0}, 114 | scaleXY = { 115 | x = "$scaleX", 116 | y = "$scaleY"}}, 117 | { 118 | _id = "drawPolygon2", 119 | _type = "DrawPolygon", 120 | borderWidth = 1, 121 | scaleX = "$minScale", 122 | scaleY = "$minScale", 123 | x = 517, 124 | y = 430, 125 | c4f = { 126 | a = 0.5, 127 | b = 0, 128 | g = 1, 129 | r = 0}, 130 | fillColor = { 131 | a = 0.2, 132 | b = 0.5, 133 | g = 0, 134 | r = 0}, 135 | scaleXY = { 136 | x = "$scaleX", 137 | y = "$scaleY"}}, 138 | { 139 | _id = "drawCardinalSpline2", 140 | _type = "DrawCardinalSpline", 141 | scaleX = "$minScale", 142 | scaleY = "$minScale", 143 | segments = 100, 144 | tension = 5, 145 | x = 706, 146 | y = 430, 147 | scaleXY = { 148 | x = "$scaleX", 149 | y = "$scaleY"}}, 150 | { 151 | _id = "drawPoint2", 152 | _type = "DrawPoint", 153 | dot = 0, 154 | pointSize = 40, 155 | scaleX = "$minScale", 156 | scaleY = "$minScale", 157 | x = 1070, 158 | y = 430, 159 | scaleXY = { 160 | x = "$scaleX", 161 | y = "$scaleY"}}, 162 | { 163 | _id = "drawLine2", 164 | _type = "DrawLine", 165 | scaleX = "$minScale", 166 | scaleY = "$minScale", 167 | segment = 0, 168 | x = 160, 169 | y = 99, 170 | from = { 171 | x = -40, 172 | y = 0}, 173 | scaleXY = { 174 | x = "$scaleX", 175 | y = "$scaleY"}, 176 | to = { 177 | x = 40, 178 | y = 50}}, 179 | { 180 | _id = "drawLine1", 181 | _type = "DrawLine", 182 | scaleX = "$minScale", 183 | scaleY = "$minScale", 184 | segment = 1, 185 | x = 160, 186 | y = 234, 187 | from = { 188 | x = -40, 189 | y = 0}, 190 | scaleXY = { 191 | x = "$scaleX", 192 | y = "$scaleY"}, 193 | to = { 194 | x = 40, 195 | y = 50}}, 196 | { 197 | _id = "drawPolygon3", 198 | _type = "DrawPolygon", 199 | borderWidth = 1, 200 | scaleX = "$minScale", 201 | scaleY = "$minScale", 202 | x = 516, 203 | y = 234, 204 | c4f = { 205 | a = 0.5, 206 | b = 0, 207 | g = 1, 208 | r = 0}, 209 | fillColor = { 210 | a = 0, 211 | b = 0.5, 212 | g = 0, 213 | r = 0}, 214 | scaleXY = { 215 | x = "$scaleX", 216 | y = "$scaleY"}}}} -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_cell_tablecell1.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = false, 3 | _id = "TableCell1", 4 | _type = "TableCell1", 5 | height = 100, 6 | ignoreAnchor = 1, 7 | width = 480, 8 | anchor = { 9 | x = 0, 10 | y = 0}, 11 | _children = { { 12 | _id = "Member", 13 | _type = "cc.LayerColor", 14 | color = "66659bff", 15 | height = "$fill", 16 | ignoreAnchor = 0, 17 | opacity = 15, 18 | width = "$fill", 19 | scaleXY = { 20 | x = 1, 21 | y = "1"}, 22 | _children = { { 23 | _id = "avatar_left", 24 | _type = "cc.Sprite", 25 | file = "avatar.png", 26 | flippedX = 1, 27 | ignoreAnchor = 1, 28 | x = 20, 29 | y = 90, 30 | anchor = { 31 | x = 0, 32 | y = 1}, 33 | blendFunc = { 34 | dst = 771, 35 | src = 1}}, 36 | { 37 | _id = "pop_left", 38 | _type = "ccui.Scale9Sprite", 39 | file = "pop_l.png", 40 | flippedX = 1, 41 | flippedY = 1, 42 | height = 80, 43 | ignoreAnchor = 1, 44 | renderingType = 1, 45 | state = 0, 46 | width = 300, 47 | x = 110, 48 | y = 90, 49 | anchor = { 50 | x = 0, 51 | y = 1}, 52 | capInsets = { 53 | height = 10, 54 | width = 60, 55 | x = 20, 56 | y = 55}, 57 | _children = { { 58 | _id = "label_left", 59 | _type = "cc.Label", 60 | color = "000000", 61 | enableWrap = true, 62 | fontSize = 16, 63 | height = 0, 64 | ignoreAnchor = 1, 65 | overflow = 3, 66 | string = "description", 67 | width = 0, 68 | x = 26, 69 | y = 40, 70 | anchor = { 71 | x = 0, 72 | y = 0.5}, 73 | fontFile = { 74 | cn = "", 75 | en = "Verdana.ttf"}}}}}}, 76 | { 77 | _id = "Time", 78 | _type = "cc.LayerColor", 79 | color = "00c86400", 80 | height = 50, 81 | ignoreAnchor = 0, 82 | opacity = 15, 83 | width = "$fill", 84 | scaleXY = { 85 | x = 1, 86 | y = "1"}, 87 | _children = { { 88 | _id = "bg_time", 89 | _type = "ccui.Scale9Sprite", 90 | file = "aq1.png", 91 | flippedX = 1, 92 | flippedY = 1, 93 | height = "$fill", 94 | ignoreAnchor = 1, 95 | renderingType = 1, 96 | state = 0, 97 | width = "$fill", 98 | x = 240, 99 | y = 25, 100 | capInsets = { 101 | height = 24, 102 | width = 24, 103 | x = 24, 104 | y = 24}, 105 | _children = { { 106 | _id = "desc", 107 | _type = "cc.Label", 108 | enableWrap = true, 109 | fontSize = 14, 110 | height = 0, 111 | ignoreAnchor = 1, 112 | string = "12:35", 113 | width = 0, 114 | x = 240, 115 | y = 25, 116 | fontFile = { 117 | cn = "Verdana.ttf", 118 | en = "Verdana.ttf"}}}}}}, 119 | { 120 | _fold = false, 121 | _id = "Me", 122 | _type = "cc.LayerColor", 123 | color = "c80063ff", 124 | height = "$fill", 125 | ignoreAnchor = 0, 126 | opacity = 15, 127 | width = "$fill", 128 | scaleXY = { 129 | x = 1, 130 | y = "1"}, 131 | _children = { { 132 | _id = "avatar_right", 133 | _type = "cc.Sprite", 134 | file = "avatar.png", 135 | flippedX = 1, 136 | ignoreAnchor = 1, 137 | x = 460, 138 | y = 90, 139 | anchor = { 140 | x = 1, 141 | y = 1}, 142 | blendFunc = { 143 | dst = 771, 144 | src = 1}}, 145 | { 146 | _id = "pop_right", 147 | _type = "ccui.Scale9Sprite", 148 | file = "pop_r.png", 149 | flippedX = 1, 150 | flippedY = 1, 151 | height = 80, 152 | ignoreAnchor = 1, 153 | renderingType = 1, 154 | state = 0, 155 | width = 300, 156 | x = 370, 157 | y = 90, 158 | anchor = { 159 | x = 1, 160 | y = 1}, 161 | capInsets = { 162 | height = 10, 163 | width = 60, 164 | x = 20, 165 | y = 55}, 166 | _children = { { 167 | _id = "label_right", 168 | _type = "cc.Label", 169 | color = "0000ff", 170 | enableWrap = true, 171 | fontSize = 16, 172 | height = 0, 173 | ignoreAnchor = 1, 174 | overflow = 3, 175 | string = "description", 176 | width = 0, 177 | x = 150, 178 | y = 40, 179 | anchor = { 180 | x = 1, 181 | y = 0.5}, 182 | fontFile = { 183 | cn = "Verdana.ttf", 184 | en = "Verdana.ttf"}}}}}}}} -------------------------------------------------------------------------------- /src/gk/controller/SceneManager.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Created by IntelliJ IDEA. 3 | -- User: Kunkka Huang 4 | -- Date: 16/12/29 5 | -- Time: 上午10:12 6 | -- To change this template use File | Settings | File Templates. 7 | 8 | local SceneManager = {} 9 | SceneManager.sceneStack = gk.List.new() 10 | 11 | -- Use as scene 12 | function SceneManager:createScene(layerName, ...) 13 | -- init scene at first, need create edit panel on edit mode 14 | local scene = gk.Scene:create(layerName) 15 | gk.profile:start("SceneManager:createScene") 16 | local layer = gk.injector:inflateContainer(layerName, ...) 17 | gk.profile:stop("SceneManager:createScene", layerName) 18 | if layer then 19 | if gk.mode ~= gk.MODE_RELEASE or gk.display:iPhoneX() then 20 | -- wrap node in editor panel 21 | local node = cc.Node:create() 22 | node:addChild(layer) 23 | node:setPosition(cc.p(gk.display.leftWidth + gk.display.extWidth / 2 + gk.display.iPhoneXExtWidth / 2, gk.display.bottomHeight)) 24 | scene:addChild(node) 25 | else 26 | scene:addChild(layer) 27 | end 28 | scene.layer = layer 29 | if gk.mode ~= gk.MODE_RELEASE then 30 | gk.event:post("displayNode", layer) 31 | gk.event:post("displayDomTree") 32 | end 33 | return scene, true 34 | end 35 | gk.log("SceneManager:createScene error, create layer class --> %s failed", layerName) 36 | return scene, false 37 | end 38 | 39 | -- layerName:must inherit from Layer 40 | function SceneManager:push(layerName, ...) 41 | gk.log("SceneManager:push --> %s", layerName) 42 | local scene, ret = self:createScene(layerName, ...) 43 | return self:pushScene(scene), ret 44 | end 45 | 46 | function SceneManager:pushScene(scene) 47 | local director = cc.Director:getInstance() 48 | director:pushScene(scene) 49 | self.sceneStack:pushRight(scene) 50 | self:printSceneStack() 51 | return scene 52 | end 53 | 54 | function SceneManager:replace(layerName, ...) 55 | gk.log("SceneManager:replace --> %s", layerName) 56 | local scene, ret = self:createScene(layerName, ...) 57 | return self:replaceScene(scene), ret 58 | end 59 | 60 | function SceneManager:replaceScene(scene) 61 | local director = cc.Director:getInstance() 62 | director:replaceScene(scene) 63 | if self.sceneStack:size() >= 1 then 64 | self.sceneStack:popRight() 65 | end 66 | self.sceneStack:pushRight(scene) 67 | self:printSceneStack() 68 | return scene 69 | end 70 | 71 | function SceneManager:pop() 72 | gk.log("SceneManager:pop") 73 | local director = cc.Director:getInstance() 74 | if self.sceneStack:size() == 1 then 75 | if self.popToEndCallback and self.popToEndCallback() then 76 | gk.log("SceneManager popToEnd! ignore") 77 | return 78 | end 79 | end 80 | director:popScene() 81 | self.sceneStack:popRight() 82 | self:printSceneStack() 83 | end 84 | 85 | function SceneManager:getRunningScene() 86 | return self.sceneStack:size() >= 1 and self.sceneStack:right() or nil 87 | end 88 | 89 | function SceneManager:popToRootScene() 90 | gk.log("SceneManager:popToRootScene") 91 | cc.Director:getInstance():popToRootScene() 92 | while self.sceneStack:size() > 1 do 93 | self.sceneStack:popRight() 94 | end 95 | end 96 | 97 | function SceneManager:showDialog(dialogType, ...) 98 | local scene = SceneManager:getRunningScene() 99 | if scene and scene.layer and scene.layer.showDialogNode then 100 | return scene.layer:showDialog(dialogType, ...) 101 | else 102 | gk.log("SceneManager:showDialogNode error, cannot find root layer") 103 | return nil 104 | end 105 | end 106 | 107 | function SceneManager:showDialogNode(dialogNode) 108 | local scene = SceneManager:getRunningScene() 109 | if scene and scene.layer and scene.layer.showDialogNode then 110 | return scene.layer:showDialogNode(dialogNode) 111 | else 112 | gk.log("SceneManager:showDialogNode error, cannot find root layer") 113 | return nil 114 | end 115 | end 116 | 117 | -- show notification node with duration 118 | function SceneManager:showNotificationNode(node) 119 | cc.Director:getInstance():setNotificationNode(node) 120 | node:runAction(cc.Sequence:create(cc.DelayTime:create(node:getDuration() - 0.016), cc.CallFunc:create(function() 121 | cc.Director:getInstance():setNotificationNode(cc.Node:create()) 122 | end))) 123 | end 124 | 125 | -- show notification node with duration 126 | function SceneManager:showNotification(nodeType, ...) 127 | local node = gk.injector:inflateNode(nodeType, ...) 128 | cc.Director:getInstance():setNotificationNode(node) 129 | node:runAction(cc.Sequence:create(cc.DelayTime:create(node:getDuration() - 0.016), cc.CallFunc:create(function() 130 | cc.Director:getInstance():setNotificationNode(cc.Node:create()) 131 | end))) 132 | return node 133 | end 134 | 135 | local function printDialogStack(layer, indent) 136 | if layer.dialogsStack then 137 | for i = 1, #layer.dialogsStack do 138 | local d = layer.dialogsStack[i] 139 | if d.__dialogType then 140 | gk.log(indent .. "[" .. d.__dialogType .. "]") 141 | printDialogStack(d, indent .. indent) 142 | else 143 | gk.log(indent .. "[???]") 144 | end 145 | end 146 | end 147 | end 148 | 149 | function SceneManager:printSceneStack() 150 | gk.log("*********************** SceneStack ***********************") 151 | for i = self.sceneStack.first, self.sceneStack.last do 152 | local s = self.sceneStack[i] 153 | gk.log(s.__sceneType or "unknown SceneType") 154 | if s.layer then 155 | printDialogStack(s.layer, " ") 156 | end 157 | end 158 | gk.log("*********************** SceneStack ***********************\n") 159 | gk.event:post("displayDomTree") 160 | end 161 | 162 | return SceneManager -------------------------------------------------------------------------------- /src/demoapp/gen/layout/demoapp_mainlayer.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _id = "MainLayer", 3 | _type = "MainLayer", 4 | enableKeyPad = 1, 5 | height = "$fill", 6 | ignoreAnchor = 0, 7 | popOnBack = 1, 8 | width = "$fill", 9 | _children = { { 10 | _id = "layerColor1", 11 | _lock = 0, 12 | _type = "cc.LayerColor", 13 | color = "646464ff", 14 | height = "$accuWin.h", 15 | ignoreAnchor = 0, 16 | width = "$accuWin.w", 17 | scaleXY = { 18 | x = "$scaleX", 19 | y = "$scaleY"}}, 20 | { 21 | _fold = false, 22 | _id = "bottom", 23 | _lock = 0, 24 | _type = "cc.LayerGradient", 25 | endOpacity = 255, 26 | height = 112, 27 | ignoreAnchor = 0, 28 | startOpacity = 255, 29 | width = "$fill", 30 | anchor = { 31 | x = 0, 32 | y = 0}, 33 | endColor = { 34 | a = 255, 35 | b = 248, 36 | g = 248, 37 | r = 248}, 38 | scaleSize = { 39 | h = "$minScale", 40 | w = 1}, 41 | scaleXY = { 42 | x = "$scaleX", 43 | y = "$scaleY"}, 44 | startColor = { 45 | a = 255, 46 | b = 200, 47 | g = 200, 48 | r = 200}, 49 | vector = { 50 | x = 0, 51 | y = -1}, 52 | _children = { { 53 | _fold = true, 54 | _id = "label2", 55 | _type = "cc.Label", 56 | color = "1aad02", 57 | enableWrap = true, 58 | fontSize = 24, 59 | height = 0, 60 | ignoreAnchor = 1, 61 | scaleX = "$minScale", 62 | scaleY = "$minScale", 63 | string = "@chats", 64 | width = 0, 65 | x = 80, 66 | y = 22, 67 | fontFile = { 68 | en = "Arial"}, 69 | scaleXY = { 70 | x = "$scaleX", 71 | y = "$scaleY"}}, 72 | { 73 | _fold = true, 74 | _id = "label3", 75 | _type = "cc.Label", 76 | color = "1aad02", 77 | enableWrap = true, 78 | fontSize = 24, 79 | height = 0, 80 | ignoreAnchor = 1, 81 | scaleX = "$minScale", 82 | scaleY = "$minScale", 83 | string = "@contacts", 84 | width = 0, 85 | x = 250, 86 | y = 22, 87 | fontFile = { 88 | en = "Arial"}, 89 | scaleXY = { 90 | x = "$scaleX", 91 | y = "$scaleY"}}, 92 | { 93 | _fold = true, 94 | _id = "label4", 95 | _type = "cc.Label", 96 | color = "1aad02", 97 | enableWrap = true, 98 | fontSize = 24, 99 | height = 0, 100 | ignoreAnchor = 1, 101 | scaleX = "$minScale", 102 | scaleY = "$minScale", 103 | string = "@discover", 104 | width = 0, 105 | x = 450, 106 | y = 22, 107 | fontFile = { 108 | en = "Arial"}, 109 | scaleXY = { 110 | x = "$scaleX", 111 | y = "$scaleY"}}, 112 | { 113 | _fold = true, 114 | _id = "label5", 115 | _type = "cc.Label", 116 | color = "1aad02", 117 | enableWrap = true, 118 | fontSize = 24, 119 | height = 0, 120 | ignoreAnchor = 1, 121 | scaleX = "$minScale", 122 | scaleY = "$minScale", 123 | string = "@me", 124 | width = 0, 125 | x = 600, 126 | y = 22, 127 | fontFile = { 128 | en = "Arial"}, 129 | scaleXY = { 130 | x = "$scaleX", 131 | y = "$scaleY"}}}}, 132 | { 133 | _fold = false, 134 | _id = "top", 135 | _lock = 0, 136 | _type = "cc.LayerGradient", 137 | endOpacity = 255, 138 | height = 112, 139 | ignoreAnchor = 1, 140 | startOpacity = 255, 141 | width = "$fill", 142 | y = 1280, 143 | anchor = { 144 | x = 0, 145 | y = 1}, 146 | endColor = { 147 | a = 255, 148 | b = 67, 149 | g = 62, 150 | r = 63}, 151 | scaleSize = { 152 | h = "$minScale", 153 | w = 1}, 154 | scaleXY = { 155 | x = "$scaleX", 156 | y = "$scaleY"}, 157 | startColor = { 158 | a = 255, 159 | b = 51, 160 | g = 45, 161 | r = 46}, 162 | vector = { 163 | x = 0, 164 | y = -1}, 165 | _children = { { 166 | _id = "label1", 167 | _type = "cc.Label", 168 | enableWrap = true, 169 | fontSize = 32, 170 | height = 0, 171 | ignoreAnchor = 1, 172 | scaleX = "$minScale", 173 | scaleY = "$minScale", 174 | string = "@app_name", 175 | width = 0, 176 | x = 360, 177 | y = 56, 178 | fontFile = { 179 | en = "Arial"}, 180 | scaleXY = { 181 | x = "$scaleX", 182 | y = "$scaleY"}}}}, 183 | { 184 | _fold = true, 185 | _id = "tableView1", 186 | _type = "cc.TableView", 187 | cellAtIndex = "&cellAtIndex", 188 | cellNums = "&cellNumsOfTableView", 189 | cellSizeForIndex = "&cellSizeForTable", 190 | direction = 1, 191 | height = 0, 192 | ignoreAnchor = 0, 193 | scaleX = "$xScale", 194 | scaleY = "$xScale", 195 | verticalFillOrder = 0, 196 | width = 0, 197 | y = 112, 198 | anchor = { 199 | x = 0, 200 | y = 0}, 201 | scaleSize = { 202 | h = "$minScale", 203 | w = 1}, 204 | scaleXY = { 205 | x = "$scaleX", 206 | y = "$minScale"}, 207 | viewSize = { 208 | height = 978, 209 | width = 720}}}} -------------------------------------------------------------------------------- /src/gk/test/gen/layout/gk_test_solarsystem.lua: -------------------------------------------------------------------------------- 1 | return { 2 | _fold = true, 3 | _id = "solarSystem1", 4 | _type = "SolarSystem", 5 | height = "$fill", 6 | width = "$fill", 7 | _children = { { 8 | _id = "drawNodeCircle1", 9 | _type = "DrawNodeCircle", 10 | radius = 10, 11 | scaleX = "$minScale", 12 | scaleY = "$minScale", 13 | x = 640, 14 | y = 384, 15 | c4f = { 16 | a = 1, 17 | b = 0, 18 | g = 0, 19 | r = 0.8}, 20 | scaleXY = { 21 | x = "$scaleX", 22 | y = "$scaleY"}, 23 | _children = { { 24 | _id = "particleSystemQuad1", 25 | _type = "cc.ParticleSystemQuad", 26 | angleVar = 360, 27 | life = 1, 28 | lifeVar = 0.2, 29 | particle = "gk/res/particle/Galaxy.plist", 30 | speed = 10, 31 | speedVar = 1, 32 | startSize = 5, 33 | startSizeVar = 1, 34 | startSpin = 0, 35 | totalParticles = 50, 36 | x = 10, 37 | y = 10, 38 | posVar = { 39 | x = 2, 40 | y = 2}, 41 | sourcePosition = { 42 | x = 0, 43 | y = 0}, 44 | startColor = { 45 | a = 1, 46 | b = 0.75999999046326, 47 | g = 0.25, 48 | r = 0.9}}}}, 49 | { 50 | _id = "circle_mercury", 51 | _type = "DrawNodeCircle", 52 | radius = 40, 53 | rotation = 23, 54 | scaleX = "$minScale", 55 | scaleY = "$minScale", 56 | skewX = 55.1, 57 | x = 640, 58 | y = 384, 59 | c4f = { 60 | a = 0.5, 61 | b = 0, 62 | g = 1, 63 | r = 0}, 64 | scaleXY = { 65 | x = "$scaleX", 66 | y = "$scaleY"}, 67 | _children = { { 68 | _id = "mercury", 69 | _type = "DrawNodeCircle", 70 | radius = 1.149, 71 | skewX = -55.1, 72 | solid = 0, 73 | x = 100, 74 | y = -60}}}, 75 | { 76 | _id = "circle_venus", 77 | _type = "DrawNodeCircle", 78 | radius = 70, 79 | rotation = 23, 80 | scaleX = "$minScale", 81 | scaleY = "$minScale", 82 | skewX = 55.1, 83 | x = 640, 84 | y = 384, 85 | c4f = { 86 | a = 0.5, 87 | b = 0, 88 | g = 1, 89 | r = 0}, 90 | scaleXY = { 91 | x = "$scaleX", 92 | y = "$scaleY"}, 93 | _children = { { 94 | _id = "venus", 95 | _type = "DrawNodeCircle", 96 | radius = 2.85, 97 | skewX = -55.1, 98 | solid = 0, 99 | x = 90, 100 | y = -30}}}, 101 | { 102 | _id = "circle_earth", 103 | _type = "DrawNodeCircle", 104 | radius = 100, 105 | rotation = 23, 106 | scaleX = "$minScale", 107 | scaleY = "$minScale", 108 | skewX = 55.1, 109 | x = 640, 110 | y = 384, 111 | c4f = { 112 | a = 0.5, 113 | b = 1, 114 | g = 1, 115 | r = 0}, 116 | scaleXY = { 117 | x = "$scaleX", 118 | y = "$scaleY"}, 119 | _children = { { 120 | _id = "earth", 121 | _type = "DrawNodeCircle", 122 | radius = 3, 123 | skewX = -55.1, 124 | solid = 0, 125 | x = 100, 126 | c4f = { 127 | a = 1, 128 | b = 1, 129 | g = 1, 130 | r = 0}, 131 | _children = { { 132 | _id = "circle_moon", 133 | _type = "DrawNodeCircle", 134 | lineWidth = 0.5, 135 | radius = 6, 136 | rotation = -5, 137 | skewX = 55.1, 138 | x = 3, 139 | y = 3, 140 | c4f = { 141 | a = 0.5, 142 | b = 1, 143 | g = 1, 144 | r = 1}, 145 | _children = { { 146 | _id = "moon", 147 | _type = "DrawNodeCircle", 148 | radius = 1.5, 149 | skewX = -55.1, 150 | solid = 0, 151 | x = 3, 152 | c4f = { 153 | a = 1, 154 | b = 1, 155 | g = 0, 156 | r = 1}}}}}}}}, 157 | { 158 | _id = "circle_mars", 159 | _type = "DrawNodeCircle", 160 | radius = 150, 161 | rotation = 23, 162 | scaleX = "$minScale", 163 | scaleY = "$minScale", 164 | skewX = 55.1, 165 | x = 660, 166 | y = 384, 167 | c4f = { 168 | a = 0.5, 169 | b = 0, 170 | g = 1, 171 | r = 0}, 172 | scaleXY = { 173 | x = "$scaleX", 174 | y = "$scaleY"}, 175 | _children = { { 176 | _id = "mars", 177 | _type = "DrawNodeCircle", 178 | radius = 1.596, 179 | skewX = -55.1, 180 | solid = 0, 181 | x = 150, 182 | y = 50}}}, 183 | { 184 | _id = "circle_jupiter", 185 | _type = "DrawNodeCircle", 186 | radius = 520, 187 | rotation = 23, 188 | scaleX = "$minScale", 189 | scaleY = "$minScale", 190 | skewX = 55.1, 191 | x = 640, 192 | y = 384, 193 | c4f = { 194 | a = 0.5, 195 | b = 0, 196 | g = 1, 197 | r = 0}, 198 | scaleXY = { 199 | x = "$scaleX", 200 | y = "$scaleY"}, 201 | _children = { { 202 | _id = "jupiter", 203 | _type = "DrawNodeCircle", 204 | radius = 32.91, 205 | skewX = -55.1, 206 | solid = 0, 207 | x = 560, 208 | y = 420}}}, 209 | { 210 | _id = "circle_saturn", 211 | _type = "DrawNodeCircle", 212 | drawLineToCenter = 1, 213 | radius = 950, 214 | rotation = 23, 215 | scaleX = "$minScale", 216 | scaleY = "$minScale", 217 | skewX = 55.1, 218 | x = 640, 219 | y = 384, 220 | c4f = { 221 | a = 0.5, 222 | b = 0, 223 | g = 1, 224 | r = 0}, 225 | scaleXY = { 226 | x = "$scaleX", 227 | y = "$scaleY"}, 228 | _children = { { 229 | _id = "saturn", 230 | _type = "DrawNodeCircle", 231 | radius = 27.42, 232 | skewX = -55.1, 233 | solid = 0, 234 | x = 1010, 235 | y = 850}}}}} --------------------------------------------------------------------------------