Hi
I am trying to make car engine sound by using SimpleAudioEngine .
i can use this engine on my menu loop without problem
this works fine
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:#"menuLoop.wav"];
But i cannot use any of playEffect metods
[[SimpleAudioEngine sharedEngine] playEffect:#"engine.wav"];
[[SimpleAudioEngine sharedEngine] playEffect:#"engine.wav" pitch:0.5f pan:0.6f gain:1.0f];
both of them dont working on simulator or device
Plz help me out...
Make sure your wave file is using format that is supported by CocosDenshion. as explained here: http://www.cocos2d-iphone.org/wiki/doku.php/cocosdenshion:faq#i_ve_got_some_wave_files_but_they_don_t_work_what_can_i_do
You can try using afconvert tool to fix the file:
afconvert -v -f WAVE -d LEI16 notworking.wav working.wav
Related
I implemented a video player function with AVPlayer in Swift 3.
Currently, I can play the video well. I would like to add the feature of "Trick Play" with the speed of 2x,3x,4x.
However, I didn't find anything googling. Can anyone help me please?
Try
playerViewController.player!.rate = 2 // 3, 4 etc
What are some good practices for loading a conditional javascript file using modernizr now that yepnope and .load are deprecated in the latest version of modernizr.
Used to be able to use the .load function.
http://modernizr.com/docs/#load
Modernizr.load({
test: Modernizr.geolocation,
yep : 'geo.js',
nope: 'geo-polyfill.js'
});
Now .load is deprecated along with yepnope.
https://github.com/SlexAxton/yepnope.js/
Reference for answer prior to yepnope being deprecated
Loading Scripts Using Modernizr... Not Working
You can use jQuery's getScript method. I think you could also use .fail instead of the else statement. Spent my morning figuring this out and have been trying to answer these to save people some time!
Something like this?
if (Modernizr.geolocation) {
jQuery.getScript("geo.js")
//it worked! do something!
.done(function(){
console.log('geo.js loaded');
});
} else {
jQuery.getScript("geo-polyfill.js")
//it worked! do something!
.done(function(){
console.log('geo-polyfill.js loaded');
});
}
I'm trying to read/load an exported JSON and resources from CocosStudio(this is a tool to generate animations)
But when i try to load or read is seams that the isn't any class or function in order to load this file. I did a web research and all i found were deprecated code or external libraries etc..
thinks like:
auto animation animation = extension::ccSkeletonAnimation::createWithFile("FILE.JSON","FILE.ATLAS");
animation->setPosition((x+y));
animation->setAnimation("a",true);
this->addChild(animation,0);
The code above is using an external tool similar to "cocosStudio", called "Spin"
Is it any that can provide some guidance on this...? or the proper class to set an animation a JSON file?
The cocos2dx version is 3.1
Thanks in advance!
Best regards!
I'm using this code to import animation from cocostudio to visual studio 12
cocostudio::Armature* armature;
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("DemoPlayer0.png","DemoPlayer0.plist","DemoPlayer.ExportJson");
armature = Armature::create("DemoPlayer");
armature->setPosition(ccp(visibleSize.width * 0.8,visibleSize.height * 0.5));
armature->getAnimation()->playByIndex(0);
armature->setScale(0.25);
this->addChild(armature);
Or you can check this code in help section of cocostudio.
//async loading export file
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Cowboy0.png","Cowboy0.plist","Cowboy.ExportJson");
//Creat armature by name
CCArmature *armature = CCArmature::create("Cowboy");
//play animation by animation index
armature->getAnimation()->playByIndex(0);
//Change Permissions
armature->setScale(0.5f);
//Set the armature position
armature->setPosition(200,300);
//add to the current scene
this->addChild(armature,2)
Good luck !
I'm working on a game (with Cocos2d 3.0 and SpriteBuilder) in which a character smash another and gain impulse. To do this I'm trying the following:
-(BOOL)ccPhysicsCollisionPreSolve:(CCPhysicsCollisionPair *)pair hero:(CCNode *)hero goal:(CCNode *)goal {
[hero.physicsBody applyImpulse:ccp(0.0f, 9000)];
return TRUE;
}
And also:
-(void)ccPhysicsCollisionPostSolve:(CCPhysicsCollisionPair *)pair hero:(CCNode *)hero goal:(CCNode *)goal {
[hero.physicsBody applyImpulse:ccp(0.0f, 9000)];
}
But when the collision method is called, the character doesn't receive the impulse always. I also tried including the following inside "PostSolve" (How to make a dynamic body static in Cocos2d v3.0 with Chipmunk):
[[_physicsNode space] addPostStepBlock:^{
[hero.physicsBody applyImpulse:ccp(0.0f, 9000)];
} key:hero];
...but I have the same result. Do you hace any advice? Thank you.
There was a rather embarrassing copy paste bug in apply impulse in v3 rc1. It's fixed in RC2 though.
I'm working on a game for android using Cocos2D-android and when I'm trying to use the CCQuadParticleSystem class, the CTOR just returns null. I spent hours searching for an example or a tutorial on this and all I found was other people asking about the same exact thing. It just returns null. I have my .plist file in my assets folder - the same file which is working just great with Cocos2D-X and IOS. According to the good people at github.com it should work so I must be doing something wrong but like I said... it just returns null when I call the CTOR with or without casting:
CCQuadParticleSystem p1 = (CCQuadParticleSystem) CCQuadParticleSystem.particleWithFile("fire.plist");
CCParticleSystem p2 = CCQuadParticleSystem.particleWithFile("fire.plist");
Please, anyone ???
if It's of use, this is the .plist file I'm working with
Have a look on this example :
link for plist
you'll get the way how to handle plist file .