Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.varFamily:cocos-ui-libgdx:0.1.4'
}
dependencies {
implementation("com.github.varFamily:cocos-ui-libgdx:0.1.4")
}
<dependency>
<groupId>com.github.varFamily</groupId>
<artifactId>cocos-ui-libgdx</artifactId>
<version>0.1.4</version>
</dependency>
libraryDependencies += "com.github.varFamily" % "cocos-ui-libgdx" % "0.1.4"
:dependencies [[com.github.varFamily/cocos-ui-libgdx "0.1.4"]]
虽然Cocos Studio已经处于实质上被官方放弃的状态,但是本项目依然不定期维护。 注意:必须把cocostudio的"编辑"选择 "拖动改变尺寸"
图片来自网络,学习之用,如有侵权,请通知删除 <img src="docs/screenshot-1.gif" width="600px"/> <img src="docs/screenshot-3.gif" width="600px"/> <img src="docs/screenshot-2.gif" width="600px"/>
在build.gradle
中添加
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.varFamily:cocos-ui-libgdx:0.1.4'
compile 'com.github.tianqiujie:nativefont:2.5.0'
}
在代码中
FileHandle defaultFont = defaultFont = Gdx.files.internal("share/MLFZS.TTF");;
CocoStudioUIEditor editor = new CocoStudioUIEditor(
Gdx.files.internal("demo/MainScene.json"), null, null, defaultFont, null);
Group group = editor.createGroup();
使用AssetManager
//load
assetManager = new AssetManager();
assetManager.setLogger(new Logger("hehehe", Logger.DEBUG));
assetManager.setLoader(CocosScene.class, new CocosLoader(new InternalFileHandleResolver()));
assetManager.load("mainscene/MenuScene.json", CocosScene.class);
//render
if (!init) {
if (assetManager.update()) {
init = true;
initUi();
}
}
//initUi
CocosScene cocosScene = assetManager.get("mainscene/MenuScene.json", CocosScene.class);
root = cocosScene.getRoot();
stage.addActor(cocosScene.getRoot(assetManager));
Gdx.input.setInputProcessor(stage);
###详细demo请看AMScreen
项目使用gradle管理,直接运行./gradlew build
即可。
如果需要运行demo,执行./gradlew demo
即可。
##有问题反馈 在使用中有任何问题,欢迎用以下方式进行反馈