Closed jie-meng closed 6 months ago
2. copy my res and src files to the new project
Axmol is not 100% API compatible with Cocos2d-x, so copying files across like that is perhaps not the best idea.
add this audio.lua to axmol/framework which is previous cocos2dx lua file, missing in axmol. And the implementation need to change to cc.AudioEngine:play2d(filename, isLoop, 1.0)
The audio.lua
was never part of Axmol, so "missing" is a little misleading. The audio.lua
is from Cocos2d-x v3, and it was never part of Cocos2d-x v4, which is what Axmol was forked from. audio.lua
was also based on the old audio engine in Cocos2d-x v3, which was deprecated or removed in Cocos2d-x v4.
Regardless of that, it is unreasonable to just copy code over meant for one engine into another engine and expect it to work, and it's hard to tell if the issues/bugs you're seeing are Axmol-related or a caused by incompatible Cocos2d-x LUA code that was copied across. The most likely case is that issues you are facing are as a result of incompatible LUA code copied into the project.
So, to not waste your time in looking for issues that aren't there, it may be best to create a new project, and migrate over to Axmol by implementing the functionality you need in the new project, using your existing LUA project as a reference; just do not copy across code unless you know it's going to work.
Could axmol provide one or two sample games for developers to follow? As I remembered, there is a insect clear game (kill ants and spiders) in cocos2dx sample. With this kind of tutorial sample game, the developers can know better how to use the Axmol API. And it also can be a better way to test Axmol engine on all the platforms.
That requires time and effort for someone to implement such things, and as this is an open source project, it may happen over time, but there can be no expectation placed on maintainers or contributors to do this.
Is there any reason you don't use the <axmol>/tests/lua-tests
project as a reference? As far as I can tell, it has all the functionality demonstrated in there.
It may be best to create a new project, and migrate over to Axmol by implementing the functionality you need in the new project, using your existing LUA project as a reference; just do not copy across code unless you know it's going to work. --- this is what am I doing now
Is there any reason you don't use the
--- This is a good approach, thanks for your advice, lua-tests already have enough lua api examples to follow, one more question, how to compile and run lua tests from command line?
1 - In Powershell, navigate to the <axmol>/tests/lua-tests
folder.
2 - Use the build command relevant to your platform and target, just as you would on your own project. For example, to target Windows x64 and build on the command line: axmol build -p win32
3 - To run it, axmol run
should work
axmol version: latest verison of 'dev' branch devices test on: MacBookPro M3 Max developing environments Xcode version: 15.3 cmake version: 3.29.2 Steps to Reproduce:
The print does not work issue
I created this issue and already found how to solve it. https://github.com/axmolengine/axmol/issues/1866
audio.playSound("sound.mp3") does not work issue
I add this audio.lua to axmol/framework which is previous cocos2dx lua file, missing in axmol. And the implementation need to change to cc.AudioEngine:play2d(filename, isLoop, 1.0)
Then add this line
audio = require("axmol.framework.audio")
to init.lua.touch does not work issue
My code is to add a callback "onTouch" to the newLayer, and my "onTouch" callback never triggers, I tried to add some log in the LayerEx.lua
But the log never show... I still struggling on this issue...
Summary
As a game developer, I don't want to waste too much time on check and fix game engine issues...
A suggestion: Could axmol provide one or two sample games for developers to follow? As I remembered, there is a insect clear game (kill ants and spiders) in cocos2dx sample. With this kind of tutorial sample game, the developers can know better how to use the Axmol API. And it also can be a better way to test Axmol engine on all the platforms.