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

Base64 encode/decode in cocos creator javascript


Featured Cocos2dx Games

Check for Sprite Parent

$
0
0

@Aniruddha32 wrote:

In my game, on certain action iam removing Sprites from scene

sampleSprite->removeFromParent();

but sprites are still present in the vector

std::vector<Sprite*> spriteContainer;

When i do check for parent of each sprites from vector in loop as i do need to check according to gameplay
//gameloop
spriteContainer.at(loopCount)->getParent();

Game is crashing when it tries to access those sprites which are earlier removed,
I know i have to delete those sprites from vector which iam doing later, but in gameloop call to those sprite comes before its deleted. And it crashes

So, how can in check whether sprite have parent or not
Or more like whether sprite is added to scene or not …
Help Needed.

Posts: 6

Participants: 2

Read full topic

Disable all user interaction

$
0
0

@fryderyk88 wrote:

Hi there!
At this moment, I have been disabling all user interaction by using the event dispatcher with:
Director::getInstance()->getEventDispatcher()->setEnabled(false);

It worked flawlessly in the past but now I have faced a use case where I need the user interaction disabled but the event dispatcher enabled (because it must send some other type of events).

Is there any elegant solution for this? (note: placing a layer on top of the scene to swallow touches is not an option because it requires a lot of extra logic, I’m using the disable feature a lot).

Maybe it would be nice to add a method to the event dispatcher to only disable this kind of events.

Thanks in advance :slight_smile:
fryderyk

Posts: 1

Participants: 1

Read full topic

[ASK] Can i import project in cocos studio or cocos creator

$
0
0

@handi45 wrote:

Hi.
I’m new to cocos2d
I was given a code sample like this to learn by my friend … but for a long time I didn’t open it …

Screenshot_1

how do i import this project at cocos studio / cocos creator …
Please help…

Posts: 1

Participants: 1

Read full topic

Building cocos2d-x-3.17 with Visual Studio 2017 hits 0x000007b

$
0
0

@CuriousCocos wrote:

Hello dear forum!

I am trying to build cocos2d-x-3.17 with Visual Studio 2017 15.8.4 but am failing.

Commands I ran to create my project:
python setup.py
cocos new -l cpp -p com.gamefromscratch.gamename -d C:\path\to\game\here gamename
as stated here: http://www.gamefromscratch.com/post/2014/09/29/Cocos2D-x-Tutorial-Series-Installation-Creating-a-Project-and-Hello-World.aspx

First I tried to build but it told me I need to retarget the Windows SKD due to it trying to get some 8.1 or 6.1, so I put it to 10.0.17134.0.
Then it complained about “msvcr110.dll” missing, which is part of in my system32 though. Okay, so put a copy in my build-folder. I also have Visual Studio 2015 Redistributable installed.
And now, on both “Debug” and “Release” I hit following error when executing:

The application was unable to start correctly (0x000007b). Click OK to close the application.

Which seems to be related to missing DLL, so I assume that “msvcr110.dll” is incorrect or something?

I would be grateful if someone could help me : ) Thanks for your time!

Posts: 1

Participants: 1

Read full topic

[Game][Android] Blockhead

$
0
0

@Indecyfer wrote:

Hey guys, so Indecyfer just dropped our second game, called Blockhead, in the Google Play Store today.

It’s a casual game, and though the controls might be a little tough to get the hang of, it’s pretty great once you get it! Help me out and rate it if you have a good time!

Collect the stars to unlock different costumes!



Here’s the link:
https://play.google.com/store/apps/details?id=com.Indecyfer.Blockhead

Thank you!

Posts: 1

Participants: 1

Read full topic

How to get tangent angle of point


If using ui:: function, android build is failed

$
0
0

@temsini wrote:

CUiScene.h

		void sliderMove(Ref* ref, ui::Slider::EventType type);
		void sliderTouch(Ref* ref, ui::Widget::TouchEventType type);

CUiScene.cpp
void CUiScene::sliderMove(Ref * ref, ui::Slider::EventType type)
{
if (type == ui::Slider::EventType::ON_PERCENTAGE_CHANGED) {
auto obj = this->getChildByName(“dice”);
auto slider = (ui::Slider*)ref;
float Slider_Percentage = slider->getPercent();

					//obj->setScale(Slider_Percentage / 20);
					obj->setPositionX(Slider_Percentage*10);

					if (AudioEngine::getState(sound_index) == AudioEngine::AudioState::PLAYING) {		
						experimental::AudioEngine::setVolume(sound_index, Slider_Percentage);		
					}

					auto load = (ui::LoadingBar*)this->getChildByName("BgBar")->getChildByName("LD");
					load->setPercent(Slider_Percentage);
				}
			}

			void CUiScene::sliderTouch(Ref * ref, ui::Widget::TouchEventType type)
			{
				if (type == ui::Widget::TouchEventType::ENDED) {	
					auto slider = (ui::Slider*)ref;
					float Slider_Percentage = slider->getPercent();		
					if (Slider_Percentage <= 12.5f) {	
						slider->setPercent(0);
					}
					else if (Slider_Percentage > 12.5f && Slider_Percentage<=37.5f) {
						slider->setPercent(25);
					}
					else if (Slider_Percentage > 37.5f && Slider_Percentage <= 62.5f) {
						slider->setPercent(50);
					}
					else if (Slider_Percentage > 62.5 && Slider_Percentage <= 87.5f) {
						slider->setPercent(75);
					}
					else {
						slider->setPercent(100);
					}
				}
			}

if i using ui functions, and build for android, build is fail
because of not added front of ui, cocos2d::
if i change all ui:;~ to cocos2d::ui::~, problem is solved.
but I want only using ui::~
in VS2017, I using USING_NS_CC, so I didn’t write cocos2d:;~
but android build has problem.
how can I fix this problem?

Posts: 1

Participants: 1

Read full topic

Scaling animation changes (x,y) position

$
0
0

@atranredemption wrote:

Hello!

I have an animation that only changes a prefab’s scaling in the X/Y direction.

However, when I trigger this animation in quick succession for some reason the node’s position coordinates change.

When I trigger the animation, wait, then trigger again then the position coordinates are stable.

Thanks in advance for your help!

Posts: 2

Participants: 2

Read full topic

Contact on physics scene not triggering

$
0
0

@kakos wrote:

in init function my listener is;

auto contactListener = EventListenerPhysicsContact::create();
contactListener->onContactBegin = CC_CALLBACK_1(HelloWorld::onContactBegin, this);
this->_eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this);

bool HelloWorld::onContactBegin(PhysicsContact& contact) {
    CCLOG("Something Contact: %f", 1);
    return true;
}

build works without error but onContactBegin not triggered when contact occoured. I tried with lamba function version but not triggering

Posts: 1

Participants: 1

Read full topic

cc.NodePool Remove Rigid body from prefabs child node

$
0
0

@Rutudhvaj wrote:

I am developing a game like flappy dunk in CocosCreator using Javascript for Facebook Instant Game.

Game Concept : it is a endless game . there is donut as main character and when click of screen donut jump and move forward towards right side. In path donut have to pass from all the rings in path.

I have created a Ring Node as prefab because i have created a prefab for that. this prefab includes 1 main node and 5 child nodes this all node have RigidBody component and Collider component.
As per my game i am adding a ring prefab dynamically and when donut pass from ring node i remove them from parent node.

First Issue : game is working fine for few mins of game play but after 15-20 mins framerate started dropping and game running very slow.

I searched and got the solution for my First Issue like if i am creating so many prefabs dynamically then i need to use cc.PoolNode to reuse the prefab node from pool. So i have implemented this in my game.

here is my code

Creating new cc.PoolNode

this.ringsNodePool = new cc.NodePool('MovingHole');

Adding Prefab to PoolNode

this.ringsNodePool.put(this.ringPrefabNode);

And getting it again from pool if there is any node available in pool

if (this.ringsNodePool.size()>0){
        hole = this.ringsNodePool.get();
}

Second Issue : when i try to get the prefab from pool it remove all the rigid body/ body data from the child nodes of prefabs.

So please help in this situation of any one can solve it.

I am using CocosCreator V1.9 + Javascript.

Posts: 1

Participants: 1

Read full topic

Node deleting instanced node from prefab deletes all instances

$
0
0

@NoSanaNoLife wrote:

I have this code in a script attached to a prefab that is instanced in my game and I want it to delete itself
delete:function(){
if(globals.DELETE) this.node.destroy()
}

but this deletes every single instanced node of that prefab, how do you delete only the instance which called the delete function?

Thanks

Posts: 1

Participants: 1

Read full topic

Use same image with sprite node and particle node as SpriteFrame

$
0
0

@ssogut wrote:

Hi,

I don’t know that it’s a problem or not, so I want to ask :slight_smile:

I created empty project with “Cocos Creator v2.02-gpi.2” and put one scene with sprite node and particle system node inside to scene. Also I added a png image to asset folder. If I use same image with sprite node and particle node as SpriteFrame, Particle System doesn’t work!

Normaly, it works with Cocos Creator v1.9.3 :slight_smile: I tried it and worked.

Thanks.



NewProject.zip (763.7 KB)

Posts: 1

Participants: 1

Read full topic

[CUTE GAME] Cat'n'Robot: Idle Defense

$
0
0

@genix_developer wrote:

Hi!

We release new game write by cocos2d-x.

Your kingdom are invaded by the monsters. Grow your cat warriors stronger, build your robot bigger to defeat the enemies. Simple, but fun to play, you’ll definitely be hooked by those epic battles.

Trailer Game

Link ANDROID:
https://play.google.com/store/apps/details?id=com.dinogo.catarmy

LINK IOS:

Hope you all fun when play.

Posts: 6

Participants: 3

Read full topic


Animated Splash Screen while Loading Assets

$
0
0

@captainflyaway wrote:

I want to animate the loading bar while loading assets.

The basic idea:

  1. create the loading bar
  2. load asset 1
  3. interpolate loading bar to 25%
  4. load asset 2
  5. interpolate loading bar to 50%
    -repeat

By default each of these steps has to be in a seperate game cycle I think (because otherwise the loading bar will not visually progress).
Also normally these steps have to be in the create method?. - so there will be no rendering at all

How do I solve this?

Posts: 1

Participants: 1

Read full topic

Android build issue with CocoCreator 2.0.0

$
0
0

@selvam wrote:

Hi Guys,

I am very new to Cocos2d and CocosCreator. Already have javascript experience.
Now i am trying to develop games for HTML5, Android & iOS platform. so why choosed Cocos2d which is very powerful tool to develop cross platform games.

Facing problem with generating Android Build (APK).

Just tried with HelloWorld project. I converted this cocos2d HelloWorld project into Android studio project by Build option which is available in CocosCreator.

While open the android studio project in Android studio i got below error while Gradle Sync.

Build command failed.

Error while executing process /Users/nancyzane/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/nancyzane/Documents/SELVAM/WORK/learning/cocos2d/NewProject/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk NDK_APPLICATION_MK=/Users/selva/Documents/SELVAM/WORK/learning/cocos2d/NewProject/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk APP_ABI=x86 NDK_ALL_ABIS=x86 NDK_DEBUG=0 APP_PLATFORM=android-21 NDK_OUT=/Users/nancyzane/Documents/SELVAM/WORK/learning/cocos2d/NewProject/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=/Users/nancyzane/Documents/SELVAM/WORK/learning/cocos2d/NewProject/build/jsb-link/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/lib NDK_TOOLCHAIN_VERSION=4.9 NDK_MODULE_PATH=/Applications/CocosCreator.app/Contents/Resources/cocos2d-x:/Applications/CocosCreator.app/Contents/Resources/cocos2d-x/cocos:/Applications/CocosCreator.app/Contents/Resources/cocos2d-x/external -j4 NDK_DEBUG=0 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}

Android NDK: Invalid APP_STL value: gnustl_static

Android NDK: Please use one of the following instead: none system c++_static c++_shared

*** Android NDK: Aborting . Stop.

Installed Software versions

Cocoscreator 2.0.0
Android Studio 3.1.4
NDK r18
java version “10.0.1” 2018-04-17
Java™ SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot™ 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

Gradle version 4.4
Android Plugin verison 3.1.0
Android Plugin Repository

Any one help to take successful APK

Thanks in advance.

Posts: 1

Participants: 1

Read full topic

Can't find correct Visual Studio's path in the registry

$
0
0

@RealFlyfishII wrote:

My first encounter with Cocos Creator. Bit disappointment though as it is the bug that should be already fixed as reported previously.

Preinstalled my VS2017 but still have that error when compiling for Windows.

Can somebody advise what registry settings the compiler is checking so I could edit the registry manually?

Building mode: release
Building…
Required VS version : [2013, 2015, 2017]
Can’t find correct Visual Studio’s path in the registry.

Posts: 1

Participants: 1

Read full topic

Sdkbox is not define

[SOlVED]Rapidjson Modifying An Array Inside An Object

$
0
0

@dragon0962 wrote:

Hi everybody !

I want to modify the “child”:[1,2,3,4] array => to [1,2,2,2] , And It does not affect other objects ( name,wife…) .

 {
   "parent": {
     "name":"Tom",
     "child":[1,2,3,4],
     "wife":"Juli"
    }
 }

I expect it works well on android and ios platform !
Could you please give me your tutorial ?
Thanks you very much !

Posts: 2

Participants: 1

Read full topic

Viewing all 17093 articles
Browse latest View live


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