How to avoid Animation data be covered by cocos2dx? - cocos2d-x

I use cocostudio to create some animation export files , it has .ExportJson , .plist , .png .And I use following code to load it in cocos2dx 3.2:
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_die/monkey_die.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_jump/monkey_jump.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_run/monkey_run.ExportJson");
But when I want play the monkey_run animation use :
cocostudio::Armature * armature = cocostudio::Armature::create("monkey_run");
addChild(armature);
armature->playWithIndex(0);
The animation is monkey_die! So I change the code :
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_run/monkey_run.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_die/monkey_die.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_jump/monkey_jump.ExportJson");
I just let run in front of die . The I can play the monkey_run correctly.
I'm green hand to cocostudio. So I think it must be the export files' problem . I use some default name in cocostudio. Which of them can cause the problem?

I got this resolved recently. It is because the same image file name. For example, in your three animations, you may have this file: monkey_head.png. Try to rename the image file into different names, like monkey_head_die.png, monkey_head_jump.png. And do the same thing for rest of images. Hope it helps.
Leo

Related

Change title of Keycloak login

I want to know how to change title on login page via Keycloak?
The easiest way is to change the following line in themes/base/login/messages/messages_[your_language].properties.
loginTitle=Log in to {0}
However, I suggest you should read the official document and create your original theme.
You can change to themes[your theme]\login\resources\css\login.css
You can add like this
/* Title */
#kc-page-title::after {
content: " to MyHomeLogin"
}
I suggest the following if you are working with a custom theme.
Go to themes/base/login.
Copy the file template.ftl
Go to themes/custom/login -> 'custom' or the name of your theme
Paste the template.ftl file there
Open template.ftl
Search for the element
Replace the content with your desired text
Save it and reload the page
I prefer this method because it only overwrites the base theme at runtime without making any changes to the base theme directly. Thanks.

What is wrong with path in gulp.spritesmith?

I used gulp.spritesmith to make a sprite image. I imported sprite.sass into main.sass and it seems to be working except there is a problem with path to images. I know it is probably some silly mistake but I can't figure out what it is so I would be really greatful if you can help me.
Here is my gulpfile fragment
gulp.task('sprite', function () {
var spriteData = gulp.src('assets/img/icons/*.png').pipe(spritesmith({
imgName: 'sprite.png',
cssName: 'sprite.sass',
imgPath: './assets/img/sprite.png'
}));
spriteData.css.pipe(gulp.dest('./assets/sass/1-tools'));
});
I'm including image
.services-item
&-design
#include sprite($heart-services)
And these is how it works in the browser.
Here is my project structure
It's been nearly 2 years. Hope you have already solved it. AFAIK, among these options of spritesmith, **imgPath ** is the request path relative to the css file rather than the project structure of SASS/images source.
Suppose your css file containing your sprite image reference is in folder ./assets/sass/, and your image is in ./assets/img/. In this case you can try change the imgPath option to:
imgPath: '../img/sprite.png' //use .. back to assets folder, then go down to img folder

Box2d MovieClip to original position

I want to try a simple task where if i move a object inside the world and then press a button it should go back to its original position , but its not working , below is the code i am using - the file is here - http://www.fastswf.com/yAnIvBs (when i remove the event listener)
with event listener - http://www.fastswf.com/rpYsIt8
////////========================
stop();
var startXPos:Number = level1WorldObj.box1.x;
var startYPos:Number = level1WorldObj.box1.y;
function areaS(e:Event) {
level1WorldObj.box1.y= startYPos;
level1WorldObj.box1.x= startXPos;
level1WorldObj.box1.removeEventListener(Event.ENTER_FRAME, areaS);
}
but1.addEventListener(MouseEvent.CLICK,nClick3);
function nClick3(event:MouseEvent):void{
level1WorldObj.box1.addEventListener(Event.ENTER_FRAME, areaS);
level1WorldObj.box1.y= startYPos;
level1WorldObj.box1.x= startXPos;
}
/////////////////======================
Now i want to be able to do it many time so i kept the variables that detect the initial x, y as global ...
Here you can see how it behaves in debugdraw mode , strangely only the clip moves not the actual body - http://www.fastswf.com/-Ijkta4
Can some one please guide me here ...
Thanks in advance ...
Jin
The graphics that you see (box1) aren't related to the physical object behind the scenes - you're currently only moving the graphics not the object itself.
You need to use either SetPosition() or SetTransform() on the b2Body of the object
Edit 07/7
As you're using the Box2D World Construction Kit, I took a look at the source code (available here: https://github.com/jesses/wck). The main class seems to be BodyShape (https://raw.githubusercontent.com/jesses/wck/master/wck/BodyShape.as).
Looking through it, you should be able to access the b2Body directly. If it's null (which is probably the source of the TypeError that you're getting, then you haven't called createBody(), which is what actually takes all of your properties as creates the physical object behind the scenes.
Once you have a b2Body, if you want to position it based on the graphics, there's a function syncTransform() to do just that.
You should turn on debugDraw on your World class to make it easier to see what's going on in the background. NOTE: this needs to be done before calling create()
I was able to find solution to this problem , i found the starting point by using this -
trace(level1WorldObj.box1.b2body.GetPosition().x);
trace(level1WorldObj.box1.b2body.GetPosition().y);
then once i had the position manually i took down the coordinates and used the below code ....
level1WorldObj.box1.b2body.SetTransform(new V2(-2, 2),0 );
Thanks #divillysausages for all the help ...
Regards

How can I create an empty ParticleSystem and add child particlesystemquad on it like CCNode

I'm making a game using cocos2d-x 3.0 alpha, and I want it to create empty ParticleSystem object(root A) and add many ParticleSystemQuads on it as children.
so I would be able to change position and scale, etc., by just changing root A only.
so I made root ParticleSystem like
ParticleSystem *A = ParticleSystem::create();
It has no error but it crashes because I didn't put plist file name. I tested with plist file name and it works, but I had to put any file to do that(of course I can do trick like moving root A particle outside from screen).
How can I make empty ParticleSystem onject like CCNode? I can just use CCNode but I want to use stopSystem() and resetSystem() methods which is in ParticleSystem class. That's why.
You may go like this way:
CCParticleSystemQuad* sun = CCParticleSun::create();
CCParticleSystemQuad* fire = CCParticleFire::create();
CCNode* root = CCNode::create();
root->addChild(sun);
root->addChild(fire);
root->setPosition(ccp(100,100));
root->setScale(2.0);
scene->addChild(root);

Only one instance of a Swiffy conversion works on page with multiple conversions?

Placing multiple swiffy conversions on the same page seems to conflict, only the first one shows up. Is there an area of code, possibly instance names, that I can change on each one so that multiple conversions can appear on the same page?
Here's a link to the page I'm talking about: http://www.ufonies.com/fansmobi.html
The animation in the header works fine, there should be another small animation under the "Space Golf" image but it just appears as a blank space, the conversion code there.
Thanks
I had this problem too with a slider - each slide was a swiffy animation and every time I used two or more animations, swiffy threw an error.
I got around this by using iframe containers for slides instead of divs - this way each animation had its own namespace for variables and scripts.
I hope this helps.
It's pretty simple actually
The swiffyobject should be renamed to anything ex. swiffyobject2, swiffyobject3 and so on.
See in this example the container is renamed to container2 so is the Element id
And then i call swiffyobject2 instead of swiffyobject. that way we can use as much instances of swiffyobjects as we want.
<div id="swiffycontainer2" style="width: 190px; height: 195px">
</div>
<script>
var stage = new swiffy.Stage(document.getElementById('swiffycontainer2'),
swiffyobject2);
stage.start();
</script>
I like to create separate js files for every object and just call one instance of
<script src="https://www.gstatic.com/swiffy/v5.2/runtime.js"></script>
but that's just a personal taste. Hope this helps.
Try to make new instance.
Example:
var swiffyIntroSlide = new swiffy.Stage(document.getElementById('intro-slide'), introSlide);
swiffyIntroSlide.start();
var swiffyBanquePopulaire = new swiffy.Stage(document.getElementById('top-banner'), banquePopulaire);
swiffyBanquePopulaire.start();
Notes:
introSlide & banquePopulaire are variables of swiffy objects.