MonoGame iPhone iPad Setup - monogame

I recently migrated a WP7 XNA app to MonoGame. When I build, I get an error saying there is no graphics device manager. Here is the code:
MonoGame.Framework.MacOS > Game.cs
private GraphicsDeviceManager graphicsDeviceManager
{
get
{
if (_graphicsDeviceManager == null)
{
_graphicsDeviceManager = (IGraphicsDeviceManager)
Services.GetService(typeof(IGraphicsDeviceManager));
if (_graphicsDeviceManager == null)
throw new InvalidOperationException ("No Graphics Device Manager");
}
return (GraphicsDeviceManager)_graphicsDeviceManager;
}
}
It appears that my game class never starts. I created a MacOS project for the game. Did I use the incorrect one? I am following these steps to make an iPad / iPhone game: http://www.facepuncher.com/blogs/10parameters/?p=42

If you create a MacOS project it will try and target MacOS. If you have MonoTouch installed you should be able to create an iOS project which will allow you to target iPhone/iPod/iPad.
The instructions from the site you posted are for a MacOS project.
We hope to include MonoGame project templates in the near future.
I hope this helps.

Related

Flutter audioplayers package: Android vs iOS

I'm quite new into flutter and coding in general. I'm trying to build a meditation app, that plays a bell every 30/60/120... seconds, depends on user input. My code works perfectly fine on Android device, but when running on iOS, it plays bell only once and doesn't play anymore. Any suggestions please? Thank you!
if (((widget.meditation.notification) != 0) &&
((_time % widget.meditation.notification) == 0)) {
print('notification $_time');
audioCache.play('audio/bell.wav');
}
Finally I found solution, simply everytime .release() must be called.
By default, the player will be release once the playback is finished or the stop method is called.
This is because on Android, a MediaPlayer instance can be quite resource-heavy, and keep it unreleased would cause performance issues if you play lots of different audios.
On iOS and macOS this doesn't apply, so release does nothing.

Cannot Change to a specific scene in Unity after building it to mobile device

Currently I'm using Application.load() to change scenes and it works perfectly in Unity. When I built it to a mobile platform and tested it, only in that one scene I can't change to a specific scene.
For example, gameplayScene, levelSelectionScene, mainMenu. I'm able to change scene from mainMenu to levelSelectionScene and then to gameplayScene. For unknown reason, I'm unable to go back to levelSelectionScene from gameplayScene while I can change scene to mainMenu from gameplayScene.
Below is the sample code from button that goes to levelSelectionScene from gameplayScene
private void OnClick ()
{
Debug.Log ("clicked");
if (PlayerPrefs.GetInt("SanguineDifficultyAchieved") == 1)
{
Debug.Log("Entering Difficulty");
m_Owner.SetActive ();
}
else
{
Debug.Log("Exiting");
State.Current = State.NotInGame;
Application.LoadLevel(scene.name);
}
m_Owner.close ();
I don't understand why it works on Unity debugger but then it doesn't work on mobile platforms.
Update 1
I tried to use numbers instead of strings it worked well. But I still don't understand the reason why.
Finally got an answer. It seems that the scenes collided with each other because I use scenes from Asset Bundle and the added scenes from build settings. That is why the when i use Application.Load(int number) works because i only access the scene from build settings.

Adapt app from iOS7 to iOS6

I wrote my application for iPhone in xcode 5.0 and it supports only 7 ios.
How can I make it available for ios 6?
Also interested in how to prevent applications load on ipad?
First question: Make sure your deployment target is 6.0, don't use API's that are iOS 7 only, or check by using
if ([someObject respondsToSelector:#selector(ios7onlymethod)] {
// do your iOS 7 only stuff
} else {
// Fall back to iOS 6-supported ways
}
Or use
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f) {
// do your iOS 7 only stuff
} else {
// Fall back to iOS 6-supported ways
}
New frameworks you want to use should be marked as optional in Xcode; to do that select your target, click general, and scroll to the "Linked Frameworks and Libraries" section.
What's really cool is that classes in frameworks marked as optional are replaced with nil on versions of iOS that don't have them. So suppose you write some code like this, using a class from the Sprite Kit framework, new in iOS 7:
SKSpriteNode *spriteNode = [SKSpriteNode spriteWithImageNamed:#"mySprite"];
On iOS 6, when the linker, which "links" frameworks to apps (apps don't copy frameworks, they just get them from the system), sees SKSpriteNode in your code, and the framework is marked as optional, that line of code will be replaced by this:
... = [nil spriteWithImageNamed:#"mySprite"];
Sending messages to nil in Objective-C does absolutely nothing, so the above code doesn't crash. No problem. So instead of lingering your code with if-statements checking for the existence of a class, you can just go with the flow and let the dynamic linker do the work.
Further reading:
iOS 7 UI Transition Guide: Supporting iOS 6
Supporting Multiple iOS Versions and Devices
Second question: There is no way to say that you want your app to only run on iPhones and iPod touches. You can require things that are specifical to the iPhone and iPod touch (like a certain processor architecture or the M7 motion coprocessor) but Apple won't like it if you require the M7 chip to exclude a certain device when you don't even need it. You should probably think about why you don't want your app to run on iPads.

Chartboost in Cocos2D-X game

I used chartboost sdk in cocos2d-x game, I can use below code in appDelegate.m and works great...but there is no c++ call for chart boost. How can I call showInterstitial API from c++ file ?
#define CHARTBOOST_APP_ID =#"Here added valid app id from chart boost account"
#define CHARTBOOST_APP_SIGNATURE #"Here added valid signature from chart boost"
Chartboost *cb = [Chartboost sharedChartboost];
cb.appId = CHARTBOOST_APP_ID;
cb.appSignature = CHARTBOOST_APP_SIGNATURE;
[cb startSession];
[cb showInterstitial];
Is there any c++ version of Chartboost SDK ?
UPDATES:
Simple solution is to use Obj.C version of Chartboost SDK, then use C++ bridge class in .mm file and access it from other .cpp file. Its simple and best way.
Here is Files: Download
There is no C++ version of the Chartboost SDK, however many developers have successfully integrated the SDK in Cocos2d games.
Often they write their own wrapper, but this developer has open sourced his:
http://www.cocos2d-x.org/projects/cocos2d-x/assets/11
https://github.com/wenbin1989/Charboost-x
Chartboost provides SDK for iOS development and Android developement.
So the answer is NO. Right now there's no SDK for C++.
Best and safe way is to write your own Obj.C and C++ bridge class.
Here is files and add objectiveC version of Chartboost sdk in Cocos2dx game
You could do something like this ...
Add this to your AppDelegate.h:
void InitChartBoost();
void ShowInterstitial();
Then create a file AppDelegate.mm and add the following methods:
void AppDelegate::InitChartBoost()
{
id appDelegate = [[UIApplication sharedApplication] delegate];
// Initialize the Chartboost library
[Chartboost startWithAppId:#"your app id"
appSignature:#"your app signature"
delegate:appDelegate];
}
void AppDelegate::ShowInsterstitial()
{
[Chartboost showInterstitial:CBLocationHomeScreen];
}

How do I run a universal app on the iPhone 3.1.3 simulator?

I'm working on a new app that I want to be universal for the iPhone and iPad. I started out with the "Create a Window-based app" wizard, and it created separate app delegates in "iPhone" and "iPad" groups. Since I already was quite familiar with iPhone dev, I did that part of my project, and now I'm ready to do some iPad stuff.
So... I started out by adding a UISplitViewController to my iPad delegate, switch the Active SDK to 3.2, and it works! But when I switch back to 3.1.3, and try to run it in the simulator, Build and Go fails. For starters, I see:
...path.../iPad/AppDelegate_Pad.h:13: error: expected specifier-qualifier-list before 'UISplitViewController'
I've got my Base SDK set to 3.2 and my Deployment Target set to 3.1.3. I thought that was enough. But I also have found in the documentation this method to conditionally compile:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
MyIPadViewController* vc;
// Create the iPad view controller
#else
MyIPhoneViewController* vc;
// Create the iPhone view controller
#endif
So do I need to do this everywhere? It seems like an awful lot of code to add (that I'll be getting rid of in a short time for 4.0 anyway) so I feel like I must be doing something wrong. And, I don't even have any idea how this works for things like #property or #synthesize declarations.
tl;dr version of the question - did I miss a setting somewhere?
I use this C function to help keep the code concise:
BOOL isPad() {
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}
Another thing I do, when I have different xib files for iPhone vs iPad. I have a stripPadSuffixOnPhone() function that helps keep the code simpler:
// Load/create the Delete table cell with delete button
self.deleteCell = [Utilities loadNib:stripPadSuffixOnPhone(#"DeleteCell~ipad")
ClassName:#"DeleteCell"
Owner:self];
Things like that can make coding more straightforward and a lot less conditionals. Still have to test everything twice though.
Quite the opposite. A universal app runs the same binary on iPhone and iPad so you cannot use conditional compilation to differentiate between the two version. But you need to use the macro Apple cites in the documentation:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// iPad-specific code
} else {
// iPhone-specific code
}
Here's what works for me:
Build your app using SDK 3.2.
Switch the active SDK to iPhone Simulator 3.1.3 (or whatever).
From the Run menu select Debug (not Build and Debug).
The binary built under 3.2 will be installed in the 3.x simulator without rebuilding. When you are finished don't forget to set your active SDK back to 3.2.