Play sound when view controller loads - c++

I'm trying to have the audio file play as soon as the view controller is loaded instead of manually hitting a button. Any suggestions?

The UIViewController has a method/function called viewDidLoad which executes when the UIViewController is loaded for the first time. If you want it to play each time it is shown, then you can use viewDidAppear
Documentation for this class is at: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html

Related

Watchkit popToRootController not working

I am using a vertical page direction on my watch app, and I have a button that opens a new interface, which opens the third interface also from a button, this is done by using the modal view, and in the third interface i am calling popToRootController, because i want to go back to the first interface, but this is not working, have anyone same issue?
You need to use dismiss if you present view controllers modally using presentControllerWithName.
You can use popToRootController or popController if you present the view controllers hierarchically using pushControllerWithName.
You can read more on the Apple Interface Navigation guide.
In your example if you want to dismiss twice, you will have to pass a delegate or closure with the context to your second controller. Then you can call the delegate method or closure after dismiss() on the third controller. The implementation of the delegate method or closure will be another dismiss().

Changing Interface Orientation for BW::Media Modal in RubyMotion

I have a RubyMotion application that is completely portrait (no landscape), but loads BW::Media.play_modal for an external MP4 video URL that I'd like to play in landscape mode.
It's loaded like this using RMQ, PM, and BW:
def on_load
rmq(#object).on(:tap) do
BW::Media.play_modal(#object.video_url)
end
end
I know how to enable autoRotate for an entire screen/controller, but is there a way to force landscape mode only when the modal is played?
Thanks in advance for any help!
Here's how I ended up solving the problem-
I enabled landscape_left and landscape_right throughout the RM app.
I set the should_autorotate method to false throughout the app.
I added a condition using PM's modal? method that set should_autorotate to true when a modal was active.
I used RMQ's rmq.orientation.landscape? method to set the view back to portrait as soon as the modal was exited.
I hope this helps if anyone else has the same problem!

Everyplay opens modal automatically after stopRecording is called

I just installed your framework successfully to my cocos2d-v3 game project. My game has short runs and I want the player to be able to share he’s single runs.
So I call startRecording when my run starts.
[[[Everyplay sharedInstance] capture] startRecording];
And stopRecording when it ends.
[[[Everyplay sharedInstance] capture] stopRecording];
But when I call stopRecording it automatically opens the video modal and I don’t want that. I want to show a replay button and when player presses the button I will call playLastRecording-method. Am I doing something wrong or why stopRecording-method opens the modal automatically?
Maybe you have copied the everyplayRecordingStopped example implementation from the Everyplay integration guide without reading the code?
https://developers.everyplay.com/documentation/Everyplay-integration-to-Cocos2d-game.md

Implementing iAd in Cocos2d V3 with MyiAd

I downloaded iAd Banner Sample for cocos2d V3. Thanks so much for that code. The demo works fine and needs the user to tap Show Ad or Hide Ad button. Of course in my game I do not want the player to tap a button to Show Ads. In IntroScene.m I commented out the code that creates the buttons and added these lines at the end of init:
AppDelegate * app = (((AppDelegate*) [UIApplication sharedApplication].delegate));
[app ShowIAdBanner];
This is the same code that would have been executed if the Show Ad button had been pressed. I expected to see an ad without having to tap a button. However, I got no ad. I got the following error message in the log:
ADBannerView: Unhandled error (no delegate or delegate does not
implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain
Code=2 "The operation couldn’t be completed. Loading throttled"
There is -(void)bannerDidFail method in AppDelegate. It works by tapping button. How do I get the ads to show up automatically, without tapping a button first? Thanks.
The error seems to tell you exactly what is happening. Make sure that you have the following line:
bannerView.delegate = self; //bannerView is an object of type AdBannerView* that you created before
Check also that the class where the previous line is, implements the method:
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
I recently wrote a tutorial on integrating iAds in Cocos2d-x v3. Although the language is different (C++ instead of Objective-C), the procedure and syntax are rather similar: http://becomingindiedev.blogspot.com.es/2015/02/integrating-iad-in-cocos2d-x-v3x.html

cocos2dx OpenGL error 0x0506 when dismissing UIViewController

I've run into very difficult issue. In the Cocos2d-x game i'm working upon currently (it's main part is written by another developer i'm just finishing it, and by now it is supposed to work on iOS only so i don't care about all the Android related stuff ) i need to use UIViewController. I present it and dismiss in a very usual way:
present:
SDMoreAppsViewController *vc = [[SDMoreAppsViewController new] autorelease];
[viewController presentViewController:vc animated:NO completion:nil];// viewController is UIWindow root view controller
dismiss:
UIViewController *controller = self.presentingViewController;
[controller dismissViewControllerAnimated:NO completion:nil];
Once the view controller is successfully dismissed i see the message in my console telling me that opengl error 0x0506 has appeared. This message is printed from methods swapBuffers of EAGLView and draw of CCSprite. Along with this message my whole scene becomes unresponsive. Tapping buttons gives no result.
I've tried a lot of things already. I tried pushing my view controller and adding it as a child instead of presenting but it doesn't even shows the view controller (viewWillAppear method doesn't get called), i also tried adding its view as a subview to my app's window but that also brings a lot of different errors.
I'm using cocos2d-x version cocos2d-2.1rc0-x-2.1.3.
Did someone solve such a problem before? Any suggestions?
before presentViewController, pause rendering:
CCDirector::sharedDirector()->pause();
CCDirector::sharedDirector()->stopAnimation();
call resume and startAnimation in completion block