I'm designing a game that has to switch between multiple game scenes. Each scene has been created in cocostudio and is imported into the code as a json file as:
var obj = ccs.load(res.Symbols_json);
this.addChild(obj.node);
This works fine, however when I have to transition to some other scene and then back to the original scene I experience several different issues.
If I create a new instance of the scene I return to as:
returnToScene: function () {
this.startScene = new startGameScene();
cc.director.runScene(new cc.TransitionFade(1,this.startScene));
}
PNG files are not loaded properly and transparency is shown as solid white. If I however keep the old instance of the scene as:
returnToScene: function () {
if (this.startScene == null) this.startScene = new startGameScene();
cc.director.runScene(new cc.TransitionFade(1,this.startScene));
}
then I have to manually reload all animations from the json file and all particle systems gets destroyed (as in they are still present but are not updated).
Have anyone else experienced anything similar? I've considered using pushScene and popScene instead of runScene but as far as I can tell it seems to be an outdated way of performing scene transitions.
Related
I have a problem in my iPhone app when trying to instantiate an ARSCNView again, after destroying it.
In my ViewController I programmatically create an ARSCNView for motion capture interaction:
func addARSceneView() {
arSceneView = ARSCNView(frame: self.view.frame)
arSceneView.loops = true
arSceneView.session.delegate = self
self.view.addSubview(arSceneView)
arSceneView.session.run(ARBodyTrackingConfiguration())
}
When the user leaves this part of the app, I tear it down like this:
func removeARSceneView() {
arSceneView.session.pause()
arSceneView.pause(self)
arSceneView.session.delegate = nil
arSceneView.removeFromSuperview()
arSceneView = nil
}
Later, when I try to instantiate an ARSCNView for the second time using the first function above, it crashes with an EXC_BAD_ACCESS in the constructor:
I also tried to use a view from a xib which contains an ARSCNView but the same problem occurs, in that case in the init(coder) function of that view.
I found nothing on this problem, I guess usually developers only create an ARSCNView once.
TLDR: Turn "Metal API Validation" on in your scheme.
I found the culprit, after creating a sample project with only the ARSCNView, which did not have this problem. I started by stripping everything away from my original project until it was as barebones as the sample. That did not solve it, so I compared every little setting of the two, and behold: in the "Run" scheme of the original project, under "Diagnostics", I had "Metal – API Validation" ticked off. I don't remember when and why I did that; I assume it was some attempt to improve performance at one point. However, enabling this checkbox solved the problem completely.
I'm absolute beginner in UrhoSharp. I only wanted to implement some basic 3D stuff into my app. Everything works fine with SimpleApplication, the screen is supposed to be watched from one place and direction. When I touch the screen, the scene rotates however. How can I get rid of this behavior?
I wanted to try to override some function of SimpleApplication (probably OnUpdate) so I came with name CursedApplication replacing SimpleApplication everywhere. When I use
using CursedApplication = Urho.SimpleApplication;
everything still works. But what I supposed to be the equivalent
class CursedApplication : Urho.SimpleApplication
{
CursedApplication(ApplicationOptions options) : base(options)
{
}
}
breaks the application. Some idea how can I make things work? Or do I have to build my own scene logic without SimpleApplication?
Finally I found that this can be done with
app.Input.Enabled=false;
where app is instance of SimpleApplication.
I'm building a game that requires levels. These levels, so that they all fit onto one page I have had to add them to a CCScrollView. This view loads automatically, as I have set in the SpriteBuilder App. The CCSrollView has been added in the MainScene.ccb file, and the content node for the scroll view is Level.ccb. What I'm trying do is have a button that is in the Level.ccb that changes the scene/content node to a level which is called Gameplay.ccb. I've tried writing the code to change the scene in the MainScene.m and Level.m files in Xcode. However these bring up an error. I'm still learning to code, so sorry if the question has been asked or has a really easy solution
- (void)levelOne {
CCScene *gameplayScene = [CCBReader loadAsScene:#"Gameplay"];
[[CCDirector sharedDirector] replaceScene:gameplayScene];
}
This piece of code is how i would switch the scene without the scrollview
If you do not understand what my problem is and would like the code send me a message and i will email you the source code
Thanks!
I have a UIViewController that after asynchronously loading some data needs to resize some child views (Some UITableViews, and some UIScrollViews). This works just fine in the simulator, but on an actual device, it hangs for a long time (as much as 30 seconds in one case). I think the problem is that it wants to recalculate everything after each changed to the child view and I would like to be able to tell it to defer any recalculations until I've resized everything, but I'm drawing a blank on finding a way to do that. Is there a mechanism to do this?
So what I'm doing is something like this (I'm using C# with Xamarin but input in Obj-C would also be appreciated!):
// Need to suspend layout here...
MyTable.Frame = new RectangleF(...);
SomeOtherTable.Frame = new RectangleF(...);
ScrollView.ContentSize = new SizeF(...);
AnotherScrollView.ContentSize = new SizeF(...);
AnotherScrollView.Frame = new RectangleF(...);
// Ok - now you can redraw!
Update: Jacob's suggestion of disabling animation didn't seem to help, but I think I've isolated the problem to the table resizing. They seem to have the biggest impact on performance, but I'm not sure why, or how to mitigate the problem. I may follow up with a separate question on that.
I'm trying to have a loading screen that pops up as soon as you run that executable that launches the game, whilst the game loads I want to display an image on the desktop much like how Gamemaker allows you to have a loading image.
I've had a brief look around and most people want an image to be shown whilst they load content which is not what I want, or perhaps it is... =P
My guess would be to set the game window borderless at the start, load the splash screen, draw it, then begin all the main loading (Specifically loading DirectInput through SlimDX takes a while). However would this support having a transparent/irregular shaped image? E.G if I wanted a borderless circle to be displayed whilst the game loads, would that be possible?
Thanks.
It's very simple. Just implement System.Threading and you're done.
Here's how it works, first add:
using System.Threading;
to the top of your class, then add the following things:
//the enum for state types
enum GameState
{
Loading,
StartMenu
}
//Init our gameState enum as variable
GameState gameState;
protected override void LoadContent()
{
gameState = GameState.Loading;
spriteBatch = new SpriteBatch(GraphicsDevice);
device = GraphicsDevice;
Window.Title = "Your Window";
//Other stuff that you had here before, now go in LoadGame()
loadingscreen = Content.Load<Texture2D>("loading");
Thread bgLoad = new Thread(new ThreadStart(LoadGame));
bgLoad.IsBackground = true;
bgLoad.Start();
}
public void LoadGame()
{
//Loading stuff here
gameState = GameState.StartMenu; //or GameState.Playing
}
and then put a loading texture in your Content Project
If I understand you correctly, you essentially want to have a window opened that is not full screen that also lacks the regular border and buttons that accompanies a window.
I can't test this but this should be a good start.
Here!
I would start by creating a bare bones Game1 class that can track an image and keep track of time for a timer.
Later you could add logic that actually tracks the loading of assets in the main program.
To start I'd just test it for a fixed time like 3 seconds.