Cocos2dx 3.10 Lua Environmental Configuration and Code Debug

Version:

Cocos2dx 3.10 Lua

Environment configuration:

Here use VS +BabeLua for editing and debugging

New project:

directly above the picture< span style="font-family:Calibri">(Pay attention to the red frame! )

-workdir D:\310\OneLua -file src\main.lua

< p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(85,85,85); font-family:'microsoft yahei'; font- size:15px; line-height:35px"> Matters needing attention:

1.Add path,The previous version has< /span>,never watched it again.Pay attention to the red frame,You have to join this.

package.path = package.path .. “;src/?.lua”

2. I don’t know which version to start from,Global variables need special instructions

cc.exports.varName = XXX

Be sure to write like this.Otherwise it will report an error

(Update 4.4: I found the problem, just set CC_DISABLE_GLOBAL = true in config.lua to false, don’t disable global variables)

3. The print function cannot output

Add engine->executeString(“print=release_print”);

or use release_print directly in the lua code (this is too troublesome, thank you for adding an underscore to a word, I can’t stand it!!!)< /span>

4. Automatic binding events

[plain] view plain copy

View code piece on CODE derived to my code piece

  1. local MainScene = class(“MainScene” , Cc.load(“mvc”).ViewBase)
  2. < span style="margin:0px; padding:0px; border:none; color:black; background-color:inherit">MainScene.RESOURCE_FILENAME=”MainScene.csb”
  3. local MainSceneEvents={[“Button_1”] ={[“varname”]=””,[“events”]={{[“event”]=”touch”,[“method”]=”OnBtnClick”}}}}
  4. MainScene.RESOURCE_BINDING=MainSceneEvents
  5. function MainScene:OnBtnClick(event)
  6. if event.name==”began”then
  7. print(“event.began” )
  8. elseif event.name==”ended” then
  9. print(“event.ended”)
  10. end li>
  11. print(event.name)
  12. end
  13. function MainScene:onCreate()
  14. end li>

transplant android cocos compile -p and roid -j 4

[ plain] view plain copy

View code piece on CODE derived to my code piece

  1. local MainScene=class(“MainScene”,cc.load(“mvc”).ViewBase)
  2. MainScene .RESOURCE_FILENAME=”MainScene.csb”
  3. local MainSceneEvents={[“Button_1”]={[“varname”]=””,[“events”]={{[“event “]=”touch”,[“method”]=”OnBtnClick”}}}}
  4. MainScene.RESOURCE_BINDING=MainSceneEvents
  5. function MainScene:OnBtnClick(event)
  6. if event. name==”began” then
  7. print(“event.began”)
  8. elseif event.name==”ended” then
  9. print(“event.ended”)
  10. end
  11. print(event.name)
  12. end li>
  13. function MainScene:onCreate()
  14. end

Porting androidcocos compile -p android -j 4 span>

< strong>[plain] view plain copy

View code piece on CODE derived to my code piece

[ plain] view plain copy

View code piece on CODE derived to my code piece


Port android cocos compile -p android -j 4