Quantcast
Channel: Cocos Forums - Latest topics
Viewing all 17076 articles
Browse latest View live

Tutorial: Getting started with WeChat games (Part VII)

$
0
0

@slackmoehrle wrote:

Cocos Creator: Getting started with WeChat games (Part VII)

Note: This is a multi-part tutorial: Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6

Introduction and getting help

You are welcome to post to the Cocos Creator category on the Cocos forums to talk about any issues you encounter during the development process. This tutorial does not teach how to code.

Please prepare your development environment before starting this tutorial. If you are having trouble with our tutorial, please take a look at the following documentation:

Preparing the development environment:


Let’s begin!

Perhaps you didn’t notice that the original name of this tutorial was: Kitten Fishing? It seems that we have not seen our kitten yet!

OK, don’t worry, the kittens will appear soon.

Starting with Animations

In this tutorial, mainly covering the animation of kittens, we also make the art resources of the entire game better through animation events.

First, let’s create two Sprite nodes in the scene, one is the kitten Cat node, and we will use animations to move it later. The second node will hold a background image. Let’s replace the original blue background we have been using.

41

Let’s start to animate the kitten. To do this, please have an understanding of Animation systems.

Next, select the Cat node and switch to the animation editor interface at the same time. If you have not adjusted the editor’s interface layout, then the animation editor is in this position:

Third, click the Add Animation Component button to add an animation component to the Cat node.

Fourth, click the New Animation Clip button in the animation editor to create a new animation clip file according to the pop-up window.

Fifth, after creating the new animation clip, click the edit button in the upper left corner of the animation editor to start editing.

43

We use frame animation to complete the kitten’s action sequence. Remember to turn off the Trim property of the Cat node, which prevents automatic cropping.

44

Sixth, click the plus button next to the property list in the animation editor. Select cc.Sprite.spriteFrame to add a track. We use the word track to describe the node animation data.

45

Seventh, drag the frame animation image resource from the Explorer to the track you just created.

Previewing

Let’s click on the Preview button to see how this game is playing and preview the new animations that were created.

47

OK, there is no problem with the animation frame sequence, but it seems that the whole animation plays a bit too fast. Let’s keep fine-tuning this game!

Fine-tuning

Adjusting the frame rate.

There are two ways to adjust the playback time of the animation frame sequence.

First method:
The default animation frame rate is 60 frames. This means that the spriteframe is being replaced every frame. Increasing the interval between each keyframe bu moving the keyframes with the mouse.

Second method:
Change the sample frame rate and speed of the animation. Changing the speed parameter from 1 to 0.5 will help! Click the edit button at the top left of the animation editor to exit editing and save.

Take a look at the Animation component in the Cat node’s Property inspector. Notice that the Cat node’s animation list already has our edited CatAnim animation.

48

The following code can be set in the script:

var anim = this.getComponent(cc.Animation);
anim.play();

or:

anim.play('CatAnim'); // play the specified animation

Note: when anim.play() has no animation name as a parameter, it will play the DefaultClip animation. This means the DefaultClip needs to be set:

49

At this point, you should feel comfortable adding a script to the Cat node and create a startAnim() method in the script to control the animation playback. It should be called by clicking the start game button and the one more game button.

startAnim () {
  var anim = this.getComponent(cc.Animation);
  anim.play('CatAnim'); // play the specified animation
}

Final adjustments

First, we need the fish hook to start to sink after the kitten’s fishing rod is played. To achieve this effect, we need to add a frame event. When the animation plays to the last frame, the hook sink code is executed through the event callback. Adding frame events is simple. If you have questions, please refer to the documentation at the start of this tutorial.

Second, open the animation, select the last keyframe, and click the AddEvent button next to the plus button in the upper left.

At this time we can see a small white mark on the timeline, this is the frame event we added

51

Double-click the small marker of the frame event, enter the callback method name and click the +,- buttons to increase or decrease the parameters.

52

After editing, click Save on the left and implement a callback method in the script of the node. Example:

var Hook = require("Hook");

cc.Class({
  extends: cc.Component,

  properties: {
    mHook : cc.Node
  },

  start () {

  },

  startAnim () {
    var anim = this.getComponent(cc.Animation);
    anim.play('CatAnim'); // play specified animation
  },

  OnAnimEnd () {
    var pHook = this.mHook.getComponent("Hook");
    pHook.StartLine();
  }
});

Last, re-adjust the click event of the start game button and one more game button.

Conclusion

You have completed all 7 parts of this tutorial. Congratulations!!.

Posts: 2

Participants: 1

Read full topic


Apple AppStore still accepting V3.17.2

$
0
0

@vkreal2 wrote:

Anyone know the Apple AppStore still accepting game made with V3.17.2? Or we need to migrate to v4?

Thanks!

Posts: 2

Participants: 2

Read full topic

Cocos Encrypt Resources.

$
0
0

@ndmh wrote:

Hi everyone ,I have an question about Encrypting resource .Why Cocos Creator don’t encrypt Resouces in APK file to avoid other developer using our resources.Thanks

Posts: 1

Participants: 1

Read full topic

JugiMap - 2d map editor

$
0
0

@Jugival wrote:

Hello everyone,

I am developing a 2d map editor called JugiMap. Along the editor I am providing also JugiMap API
which is a library for using maps from the editor in game engines.

The latest version brings a new JugiMap API which supports Cocos2d.

A screenshot from Jugimap editor:

For API development I am using a small application called API Demo Test.
Here is a screenshot of the application using Cocos2d-x engine.


The source code for the API Demo Test is provided with the API.

JugiMap is currently available for Windows OS. You can get it here: http://jugimap.com
JugiMap API is on GitHub: https://github.com/Jugilus/jugimapAPI

Posts: 1

Participants: 1

Read full topic

SDKBOX PluginReview on cocos2d-x v4.0

$
0
0

@pccsoares wrote:

Anyone managed to get SDKBOX PluginReview to work with cocos2d-x v4.0?

I don’t know how to configure the make of resources project plugin_review_res_project, and the review popup doesn’t show the text for each language.

Posts: 1

Participants: 1

Read full topic

Screen Resolution for iPhoneX

$
0
0

@Apoorva wrote:

Hi
I’m using screen resolution of (1024 x 768) with Exact Fit Policy .
But on iPhoneX images are stretched with this resolution .

So my artist made assest according to (1668 x 768) resolution .

My question is how can i fit 1668 to 1024 resolution , as my other games resources are made (1024x768) .

Please help me @slackmoehrle
Thanks

Posts: 1

Participants: 1

Read full topic

Audio Engine Problem on Cocos2dx 3.17-2

$
0
0

@arturapps wrote:

Hi people, my name is Artur.

I’ve been developing a game with cocos 2dx for since a long time, and I’ve been using Simple Audio engine on this game until recently, when I decided to change to AudioEngine (I was using cocos2dx 3.15 I’m now using cocos2dx 3.17-2).

The Audio requirements of my game are quite intensive, I would say. It is a racing game, so It has a lot of short sound effects for the bumps and craches, and looping music tracks during gameplay. In addition it has a narration voice and some other sound effects.

Sound effects are small WAV files while music tracks are bigger MP3 ones. The average specs for sound effect files are 360k of 44kHz mono WAV files and for music we have 4MB of 44kHz MP3 files.

We have been built the game for Mac, Windows, IOS and Android.

First of all, I have to say that Simple Audio Engine was doing very well. Except for some glitches on android and windows. For android, we were able to manage workarounds that keep the game very playable. But on Windows we experienced frame drops, that we investigate and confirm that are originated on the sound system.

At first, I ignored those windows problems because that were not a target platform for my game, but now things changed and my company is targeting the windows platform. Since I have beean observing the evolution of AudioEngine I decided to shift to it, in hope to solve the glitches on windows.

I did all the necessary adaptations in my code to use AudioEngine ( and it was very straight forward). Despite some initial problems , like abandoning WAV format I managed to put it to work in All my platforms including windows, and I’m very happy to say that the frame drop problem of windos has gone.

But a new big problem has appeared, and it is happening in all platforms: For some reasion, music tracks (the bigger mp3 files) are not played completly. Any music track stops someware at the middle, and never completes an entire loop. Sometimes music lasts only a few seconds. For the other sound effects everything works fine.

I have noticed that many users have been experiencing similar problems, and it seems that some have managed to fix it by changing the engine internals ( using patches). Mas estas noticias de problemas e soluções em foruns são bastante antigas (2015 to 2016) and than I think it was probably already solved on the engine.

I’m Afraid I’m missing something basic, and I would like to get some help from you people. I’m sorry I can not share all the code with you, but I would say that I’m just using AudioEngine::Play2d() for both sound effects and music. I’m nothing sending an AudioProfile on those calls ( Tryed to send one with max instances =1 for music but didnot solve the problem).

Thanks in advance.

Artur Corrêa

Posts: 1

Participants: 1

Read full topic

can i call android activity


Mouse Features (Continue Topic)

$
0
0

@lmartinignacio wrote:

To continue this topic:

@slackmoehrle @R101

I fixed the error in PR:

But it failed because it couldn’t fetch some files, this is not a problem in code, what do i do?

Error: BUILD_TARGET=android_cpp_cmake

JDK: oraclejdk8 Android

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/ninja-build/ninja-build_1.3.4-1.1ubuntu0.14.04.1_amd64.deb Connection failed

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

The command “tools/travis-scripts/before-install.sh” failed and exited with 100 during .

Your build has been stopped.

Error: BUILD_TARGET=android_lua_cmake

JDK: oraclejdk8 Android

E: Failed to fetch http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/pool/main/g/gcc-6/g++-6_6.5.0-2ubuntu1~14.04.1_amd64.deb Connection failed

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
apt-get.diagnostics

apt-get install failed

The command “sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install g+±6” failed and exited with 100 during .

@OrionSteel You can get to the code in PR in Files Changed.

Posts: 1

Participants: 1

Read full topic

CLion debug mode not working on macOS Catalina

$
0
0

@fgnoe wrote:

Hi,
I used to test my game debugging on CLion, as a cmake project, a couple days ago I updated to catalina and when I try to run my game on debug mode, it builds correctly, but the game never runs, it stays on connecting.
If I run the game without debug it runs without any problem.
does anyone know what might be causing this issue?

Posts: 1

Participants: 1

Read full topic

Audio not playing

Metal grab texture behind node

$
0
0

@Darren wrote:

Hi,

i have this functionality that uses glCopyTexImage2d to get the background texture in between renders (based on z order), to apply some blur shader to the final output image within a rectangle.
This is working well on opengl, but when porting over to metal, i am not able to get it to work.
I have found out the function for metal is to use MTLBlitCommandEncoder to copy from the drawable texture (where all the render queues will render) to the output texture.

The thing is, I realise that the rendering pipeline implementation for metal differs from opengl in that for every opengl draw call, for metal it only encodes the command to the command buffer. And only until the endFrame function that the actual rendering will perform. This pose as a hurdle to my implementation of grabbing the ‘already rendered’ texture of what’s behind my node, because it has not yet been rendered…

Would like to know what is the best practise to perform such post processing in-between renders?

Posts: 1

Participants: 1

Read full topic

What is the status of Creator and c++?

$
0
0

@Meir_yanovich wrote:

Hello
Long time i didnt checked what is new with cocos creator , but please update me
Can we develop in c++ and creator ?
If not what is the future time frame to be able to do this ?
Thanks

Posts: 1

Participants: 1

Read full topic

How to download manifest file from remote server?

$
0
0

@john_daniel wrote:

Hi everyone, I have an issue when I download manifest file from remote server using cc.loader.getXMLHttpRequest() on Android, but work well on IOS. The function onreadystatechange is not call and onerror function too, so I don’t know what is wrong. Thanks
This is my code

    try {
        cc.log("call getDataFromUrl:" + url);
        var xhr = cc.loader.getXMLHttpRequest();
        xhr.open("GET", url, true);
        xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 300)) {
                cc.log("**** call callback);
                cb && cb(xhr.responseText);
            }else{
                cc.log("*** read url: " + url + ", xhr.readyState: " + xhr.readyState + ", xhr.status: " + xhr.status);
            }
        };
        xhr.onerror = function () {
            cc.log("****** xhr request url error");
            cb && cb(null);
        }
        xhr.send();
    } catch (exception) {
        cc.log("******* request url error");
        cb && cb(null);
    }

Console output

call getDataFromUrl:http://192.168.5.106:8000/manifest/project.manifest

Posts: 1

Participants: 1

Read full topic

2.2.1 loadScene error when build android or web mobile

$
0
0

@hoanlv89 wrote:

I’m using loadscene : cc.director.loadScene(‘test’);

I run localhost in web browser , I have no error.
when i build web-mobile or android , i have error.
Uncaught TypeError: Cannot convert undefined or null to object
at Function.getOwnPropertyNames ()
at visitComponent (cocos2d-js.805bb.js:22696)
at visitNode (cocos2d-js.805bb.js:22712)
at visitNode (cocos2d-js.805bb.js:22713)
at visitNode (cocos2d-js.805bb.js:22713)
at visitNode (cocos2d-js.805bb.js:22713)
at visitNode (cocos2d-js.805bb.js:22713)
at visitNode (cocos2d-js.805bb.js:22713)
at visitNode (cocos2d-js.805bb.js:22713)
at visitNode (cocos2d-js.805bb.js:22713)

Please help me , @yinjimmy @slackmoehrle @jare

Posts: 1

Participants: 1

Read full topic


CC v2.21 - Performance issues!

$
0
0

@sledgehammer wrote:

I am shocked !

Because i read the diagram sheets of the new CC v.2.21 and they pointed out got a big performance-increase to prior versions. Sadly this is not the case, so i can´t believe these diagrams. I simply done some tests by this examples: https://github.com/cocos-creator/performance-tests

And in comparison to the prior version (CC v2.11) it was much slower on my Android. Please confirm this by doing the same test. You can only recognize this issue, when testing on a weak Android phone. Don´t use a flagship-phone. This absolutely does not make sense, for performance-testings.

So CC 2.11 is much much faster than CC 2.21 . I can´t believe it. I hope its only a bug. Beside that, v2.21 has this problems:

  • 2mb bigger *. APK (3mb bigger “lib\armeabi-v7a\libcocos2djs.so”)
  • Text “cache mode”: CHAR doensnt work
  • incompatibility with your older projects

Please dear CC-devs. Investigate into this. Its important for all of us. Thx.

Posts: 1

Participants: 1

Read full topic

Android: Crash randomly in ScriptingCore::executeFunctionWithOwner, samsung and huwei devices

$
0
0

@nhquynam wrote:

Hi guys,
I’m new to cocos2d-js, I’m developing a turn-based game, and met some random crash on Android.

  • Cocos2dx: 3.14.1, Javascript
  • Target android 28, arm-v7a, arm-v8a
  • Most crashes occured on Samsung devices, some on Xiaomi, Huwei.

Here some stack traces I’ve got from Crashlytics, but it’s not enough to determine which exactly causes the crashes.

|0|libcocos2djs.so|(Missing)|
| --- | --- | --- |
|1|libcocos2djs.so|(Missing)|
|2|libcocos2djs.so|ScriptingCore.cpp line 1565

ScriptingCore::executeFunctionWithOwner(JS::Value, char const*, unsigned int, JS::Value*, JS::MutableHandle<JS::Value>) + 1565|
|3|libcocos2djs.so|ScriptingCore.cpp line 1498

ScriptingCore::handleTouchEvent(void*, cocos2d::EventTouch::EventCode, cocos2d::Touch*, cocos2d::Event*, JS::MutableHandle<JS::Value>) + 1498|
|4|libcocos2djs.so|ScriptingCore.cpp line 1478

ScriptingCore::handleTouchEvent(void*, cocos2d::EventTouch::EventCode, cocos2d::Touch*, cocos2d::Event*) + 1478|
|5|libcocos2djs.so|functional line 2439

std::function<void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*, cocos2d::Event*) const + 2439|
|6|libcocos2djs.so|functional line 2439

std::function<bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*) const + 2439|
|7|libcocos2djs.so|CCEventDispatcher.cpp line 1070

cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*) + 1070|
|8|libcocos2djs.so|CCEventDispatcher.cpp line 912

cocos2d::EventDispatcher::dispatchEvent(cocos2d::Event*) + 912|
|9|libcocos2djs.so|CCGLView.cpp line 447

cocos2d::GLView::handleTouchesOfEndOrCancel(cocos2d::EventTouch::EventCode, int, long*, float*, float*) + 447|
|10|libcocos2djs.so|TouchesJni.cpp line 42

Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd + 42|


	libcocos2djs.so	
ScriptingCore.cpp line 1556
ScriptingCore::executeFunctionWithOwner(JS::Value, char const*, unsigned int, JS::Value*) + 1556
3	libcocos2djs.so	
cocos2d_specifics.cpp line 1289
JSScheduleWrapper::update(float) + 1289
4	libcocos2djs.so	
functional line 2439
std::function<void (float)>::operator()(float) const + 2439
5	libcocos2djs.so	
CCDirector.cpp line 277
cocos2d::Director::drawScene() + 277
6	libcocos2djs.so	
CCDirector.cpp line 1443
cocos2d::Director::mainLoop() + 1443

I guess that some objects is released in memory (perhaps by GC) but it’s still referenced somewhere in code. I also use cc.sys.isObjectValid() to check native objects before processing but it still crashes. The crash usually comes from JSScheduleWrapper::update. Is there anyway to avoid this ? Or validate object before calling executeFunctionWithOwner ?

Tks for your help.

Posts: 1

Participants: 1

Read full topic

V4 support Spine 3.8 now

$
0
0

@zhangxm wrote:

As the title says, v4 now supports Spine 3.8. You can refer to this doc about how to use Spine in v4. Or you can get latest v4 codes from github to use it.

Posts: 1

Participants: 1

Read full topic

version 2.2.1 Game crashing on launch with TypeError "Cannot read property of "Device"

$
0
0

@nicetry107 wrote:

Hello Devs,

I was using 2.1.2 before and my build ran successfully without crashes but when I opened my project with new version 2.2.1, it was running without problems on windows but game is crashing when i launch it on android devices with the mentioned error above.

Please if you have any idea about this, let me know. I need to push an important game update. Thank you.

Posts: 1

Participants: 1

Read full topic

What's for Temp folder?

$
0
0

@perfecto wrote:

Hello, just started to use CC 2.1.4, and after spent some days to use it and learn i found many “magic” things, so questions is what’s for “Temp” folder? and how is it related to a build and linking modules processes? Who could explain to me this things or where i could find to read somethings about it, thanks.

Posts: 1

Participants: 1

Read full topic

Viewing all 17076 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>