public override void ApplicationDidFinishLaunching (CCApplication application, CCWindow mainWindow) { GameAppDelegate.mainWindow = mainWindow; director = new CCDirector (); application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; application.ContentSearchPaths.Add ("animations"); application.ContentSearchPaths.Add ("fonts"); application.ContentSearchPaths.Add ("images"); application.ContentSearchPaths.Add ("levels"); application.ContentSearchPaths.Add ("sounds"); CCSize windowSize = mainWindow.WindowSizeInPixels; // Use the SNES resolution: float desiredWidth = 256.0f; float desiredHeight = 224.0f; CCScene.SetDefaultDesignResolution (desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll); mainWindow.AddSceneDirector (director); var scene = new LevelSelectScene (mainWindow); // Can skip to the GmameScene by using this line instead: //var scene = new GameScene(mainWindow); director.RunWithScene (scene); }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { GameAppDelegate.mainWindow = mainWindow; application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; application.ContentSearchPaths.Add ("Entity"); application.ContentSearchPaths.Add ("fonts"); application.ContentSearchPaths.Add ("images"); application.ContentSearchPaths.Add ("Level"); application.ContentSearchPaths.Add ("Sound"); application.ContentSearchPaths.Add ("ViewsImage"); float desiredHeight = 768.0f; float desiredWidth = 1024.0f; CCScene.SetDefaultDesignResolution (desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll); director = new CCDirector (); mainWindow.AddSceneDirector (director); var scene = new SplashScene (mainWindow); director.RunWithScene (scene); scene.PerformSplash (); CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic ("SplashBackMusic.wav",false); CCSimpleAudioEngine.SharedEngine.PreloadEffect ("BallCollideHigh.wav"); CCSimpleAudioEngine.SharedEngine.PreloadEffect ("BallCollideLow.wav"); CCSimpleAudioEngine.SharedEngine.PreloadEffect ("ballCollideBrick.wav"); }
protected override void AddedToScene() { base.AddedToScene(); // We no longer have a static director so when we remove // this in the Crash test 1 we do not have the director anymore // we will save this off so that we can issue commands to the // directory. director = Director; }
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 void RemoveSceneDirector(CCDirector sceneDirector) { sceneDirectors.Remove(sceneDirector); if (DefaultDirector == sceneDirector) { DefaultDirector = null; } // TODO: make this smarter if (sceneDirectors.Count > 0) { DefaultDirector = sceneDirectors[0]; } }
public override void ApplicationDidFinishLaunching (CCApplication application, CCWindow mainWindow) { GameAppDelegate.mainWindow = mainWindow; director = new CCDirector (); application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; application.ContentSearchPaths.Add ("animations"); application.ContentSearchPaths.Add ("fonts"); application.ContentSearchPaths.Add ("images"); application.ContentSearchPaths.Add ("levels"); application.ContentSearchPaths.Add ("sounds"); #if __IOS__ application.ContentSearchPaths.Add ("sounds/iOS/"); #else // android application.ContentSearchPaths.Add("sounds/Android/"); #endif CCSize windowSize = mainWindow.WindowSizeInPixels; // Use the SNES resolution: float desiredWidth = 256.0f; float desiredHeight = 224.0f; CCScene.SetDefaultDesignResolution (desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll); mainWindow.AddSceneDirector (director); CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic("CoinTimeSong", loop: true); // Make the audio a little quieter: CCSimpleAudioEngine.SharedEngine.EffectsVolume = .3f; var scene = new LevelSelectScene (mainWindow); // Can skip to the GmameScene by using this line instead: //var scene = new GameScene(mainWindow); director.RunWithScene (scene); }
public void RunWithScene(CCScene scene) { if (scene.Window == null) { scene.Window = this; } CCDirector sceneDirector = scene.Director; if (sceneDirector != null) { AddSceneDirector(sceneDirector); } else { sceneDirector = DefaultDirector; } sceneDirector.RunWithScene(scene); }
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 override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { GameAppDelegate.mainWindow = mainWindow; //CCDirector是处理scene这一级别的 //导演 director = new CCDirector (); //手机游戏开发时,要把PreferMultiSampling设为false //因为手机处理器不够强大 //这个抗锯齿算法很费cpu application.PreferMultiSampling = false; //asset的读取地址 application.ContentRootDirectory = "Content"; application.ContentSearchPaths.Add ("animations"); application.ContentSearchPaths.Add ("fonts"); application.ContentSearchPaths.Add ("images"); application.ContentSearchPaths.Add ("levels"); application.ContentSearchPaths.Add ("sounds"); CCSize windowSize = mainWindow.WindowSizeInPixels; // Use the SNES resolution: //设置游戏画面的大小 float desiredWidth = 256.0f; float desiredHeight = 224.0f; CCScene.SetDefaultDesignResolution (desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll); //加入导演 mainWindow.AddSceneDirector (director); //导演引入第一个scene var scene = new LevelSelectScene (mainWindow); director.RunWithScene (scene); }
void Initialise() { if (viewInitialised) { return; } PlatformInitialise(); ActionManager = new CCActionManager(); Director = new CCDirector(); EventDispatcher = new CCEventDispatcher(this); AudioEngine = new CCAudioEngine(); Scheduler = new CCScheduler(); // Latest instance of game view should be setting shared resources // Ideally, we should move towards removing these singletons altogetehr CCAudioEngine.SharedEngine = AudioEngine; CCScheduler.SharedScheduler = Scheduler; Stats = new CCStats(); InitialiseGraphicsDevice(); InitialiseResourceCaches(); InitialiseRunLoop(); InitialiseInputHandling(); Stats.Initialise(); viewInitialised = true; currentViewInstance = new WeakReference(this); }
public void RemoveSceneDirector(CCDirector sceneDirector) { sceneDirectors.Remove(sceneDirector); if (DefaultDirector == sceneDirector) DefaultDirector = null; // TODO: make this smarter if (sceneDirectors.Count > 0) DefaultDirector = sceneDirectors[0]; }
public void AddSceneDirector(CCDirector sceneDirector) { if (sceneDirector != null && !sceneDirectors.Contains(sceneDirector)) { sceneDirectors.Add(sceneDirector); } if (sceneDirectors.Count == 1) DefaultDirector = sceneDirector; }
public void SetDefaultDirector(int index) { Debug.Assert(index < sceneDirectors.Count, "CococsSharp CCWindow: index out of range."); DefaultDirector = sceneDirectors[index]; }
public CCScene(CCWindow window, CCViewport viewport, CCDirector director = null, bool physics = false)
public CCScene(CCWindow window, CCDirector director) : this(window, new CCViewport(new CCRect(0.0f, 0.0f, 1.0f, 1.0f), window.SupportedDisplayOrientations, window.CurrentDisplayOrientation), director) #endif { }
public CCScene(CCWindow window, CCDirector director) : this(window, new CCViewport(new CCRect(0.0f, 0.0f, 1.0f, 1.0f), window.SupportedDisplayOrientations), director) #endif { }
public CCScene(CCWindow window, CCDirector director) : this(window, new CCViewport(new CCRect(0.0f, 0.0f, 1.0f, 1.0f)), director) #endif { }
public CCScene(CCWindow window, CCDirector director, bool physics = false) : this(window, new CCViewport(new CCRect(0.0f, 0.0f, 1.0f, 1.0f)), director, physics)
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 void RemoveAllSceneDirectors() { sceneDirectors.Clear(); DefaultDirector = null; }
public CCTexture2D CreateCharacterTexture(CCDirector director) { const int width = 490; const int height = 278; CCSize rendSize = new CCSize(width, height); var centerPoint = new CCPoint(width / 2, height / 2); var characterTexture = new CCRenderTexture(rendSize, rendSize); characterTexture.BeginWithClear(100, 0, 0, 0); var bodySprite = CreateCustomisationSprite(); bodySprite.Position = centerPoint; bodySprite.Visit(); var armorSprite = CreateCustomisationSprite(); armorSprite.Position = centerPoint; armorSprite.Visit(); var eyesSprite = CreateCustomisationSprite(); eyesSprite.Position = centerPoint; eyesSprite.Visit(); var noseSprite = CreateCustomisationSprite(); noseSprite.Position = centerPoint; noseSprite.Visit(); var hairSprite = CreateCustomisationSprite(); hairSprite.Position = centerPoint; hairSprite.Visit(); var moustacheSprite = CreateCustomisationSprite(); moustacheSprite.Position = centerPoint; moustacheSprite.Visit(); var beardSprite = CreateCustomisationSprite(); beardSprite.Position = centerPoint; beardSprite.Visit(); var helmutSprite = CreateCustomisationSprite(); helmutSprite.Position = centerPoint; helmutSprite.Visit(); var weaponSprite = CreateCustomisationSprite(); weaponSprite.Position = centerPoint; weaponSprite.Visit(); characterTexture.End(); return characterTexture.Sprite.Texture; }
public CCAnimate CreateAnimateAction(CCDirector director) { var frameList = new List<CCSpriteFrame>(); for (var i = 0; i < 7; i++) { var texture = CreateCharacterTexture(director); var sprite = new CCSpriteFrame(texture, new CCRect(0, 0, texture.ContentSizeInPixels.Width, texture.ContentSizeInPixels.Height)); frameList.Add(sprite); } var animation = new CCAnimation(frameList, 0.1f); var animate = new CCAnimate (animation); return animate; }