public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { //application.SupportedOrientations = CCDisplayOrientation.LandscapeRight | CCDisplayOrientation.LandscapeLeft; //application.AllowUserResizing = true; //application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; CCRect boundsRect = new CCRect(0.0f, 0.0f, 960, 640); sharedViewport = new CCViewport(new CCRect (0.0f, 0.0f, 1.0f, 1.0f)); sharedWindow = mainWindow; sharedCamera = new CCCamera(boundsRect.Size, new CCPoint3(boundsRect.Center, 100.0f), new CCPoint3(boundsRect.Center, 0.0f)); mainWindow.SetDesignResolutionSize(960, 640, CCSceneResolutionPolicy.ShowAll); #if WINDOWS || WINDOWSGL || WINDOWSDX //application.PreferredBackBufferWidth = 1024; //application.PreferredBackBufferHeight = 768; #elif MACOS //application.PreferredBackBufferWidth = 960; //application.PreferredBackBufferHeight = 640; #endif #if WINDOWS_PHONE8 application.HandleMediaStateAutomatically = false; // Bug in MonoGame - https://github.com/Cocos2DXNA/cocos2d-xna/issues/325 #endif CCSpriteFontCache.FontScale = 0.6f; CCSpriteFontCache.RegisterFont("arial", 12, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 38, 50, 64); CCSpriteFontCache.RegisterFont("MarkerFelt", 16, 18, 22, 32); CCSpriteFontCache.RegisterFont("MarkerFelt-Thin", 12, 18); CCSpriteFontCache.RegisterFont("Paint Boy", 26); CCSpriteFontCache.RegisterFont("Schwarzwald Regular", 26); CCSpriteFontCache.RegisterFont("Scissor Cuts", 26); CCSpriteFontCache.RegisterFont("A Damn Mess", 26); CCSpriteFontCache.RegisterFont("Abberancy", 26); CCSpriteFontCache.RegisterFont("Abduction", 26); //sharedDirector = new CCDirector(); //director.DisplayStats = true; //director.AnimationInterval = 1.0 / 60; // if (sharedWindow.WindowSizeInPixels.Height > 320) // { // application.ContentSearchPaths.Insert(0,"HD"); // } //sharedWindow.AddSceneDirector(sharedDirector); CCScene scene = new CCScene(sharedWindow); scene.Camera = sharedCamera; CCLayer layer = new TestController(); scene.AddChild(layer); sharedWindow.RunWithScene(scene); }
void OnViewportChanged(object sender, EventArgs e) { CCViewport viewport = sender as CCViewport; if (viewport != null && viewport == Viewport) { UpdateResolutionRatios(); SceneViewportChanged(this, null); } }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; application.ContentSearchPaths.Add("animations"); application.ContentSearchPaths.Add("fonts"); application.ContentSearchPaths.Add("sounds"); CCSize windowSize = mainWindow.WindowSizeInPixels; float desiredWidth = 1024.0f; float desiredHeight = 768.0f; // This will set the world bounds to be (0,0, w, h) // Use CCSceneResolutionPolicy.Custom as we're manually setting our viewports CCScene.SetDefaultDesignResolution(desiredWidth, desiredHeight, CCSceneResolutionPolicy.Custom); // Determine whether to use the high or low def versions of our images // Make sure the default texel to content size ratio is set correctly // Of course you're free to have a finer set of image resolutions e.g (ld, hd, super-hd) if (desiredWidth < windowSize.Width) { application.ContentSearchPaths.Add("images/hd"); CCSprite.DefaultTexelToContentSizeRatio = 2.0f; } else { application.ContentSearchPaths.Add("images/ld"); CCSprite.DefaultTexelToContentSizeRatio = 1.0f; } var topViewport = new CCViewport(new CCRect(0.0f, 0.2f, .5f, 0.6f)); var bottomViewport = new CCViewport(new CCRect(0.5f, 0.0f, .5f, 1.0f)); // Each viewport needs its own director var sceneDirector1 = new CCDirector(); var sceneDirector2 = new CCDirector(); var scene1 = new CCScene(mainWindow, topViewport, sceneDirector1); var scene2 = new CCScene(mainWindow, bottomViewport, sceneDirector2); var layer1 = new GameLayer(); var layer2 = new GameLayer(); scene1.AddChild(layer1); scene2.AddChild(layer2); sceneDirector1.RunWithScene(scene1); sceneDirector2.RunWithScene(scene2); }
public CCScene(CCWindow window, CCViewport viewport, CCDirector director = null) #endif { IgnoreAnchorPointForPosition = true; AnchorPoint = new CCPoint(0.5f, 0.5f); Viewport = viewport; Window = window; Director = (director == null) ? window.DefaultDirector : director; if (window != null && director != null) { window.AddSceneDirector(director); } #if USE_PHYSICS _physicsWorld = physics ? new CCPhysicsWorld(this) : null; #endif SceneResolutionPolicy = window.DesignResolutionPolicy; }
public CCScene(CCWindow window, CCViewport viewport, CCDirector director = null, bool physics = false)
public CCScene(CCWindow window, CCViewport viewport, CCDirector director = null) #endif { IgnoreAnchorPointForPosition = true; AnchorPoint = new CCPoint(0.5f, 0.5f); Viewport = viewport; Window = window; Director = (director == null) ? window.DefaultDirector : director; if (window != null && director != null) window.AddSceneDirector(director); #if USE_PHYSICS _physicsWorld = physics ? new CCPhysicsWorld(this) : null; #endif SceneResolutionPolicy = window.DesignResolutionPolicy; }