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); }
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 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"); }
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 desiredHeight = 1024.0f; float desiredWidth = 768.0f; // This will set the world bounds to be (0,0, w, h) // CCSceneResolutionPolicy.ShowAll will ensure that the aspect ratio is preserved CCScene.SetDefaultDesignResolution (desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll); CCScene scene = new CCScene (mainWindow); GameLayer gameLayer = new GameLayer (); scene.AddChild (gameLayer); mainWindow.RunWithScene (scene); }
/// <summary> /// Called when app launched. /// </summary> /// <param name="application">application object</param> /// <param name="mainWindow">main window</param> public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; var windowSize = mainWindow.WindowSizeInPixels; var desiredHeight = 1024.0f; var desiredWidth = 768.0f; // This will set the world bounds to be (0,0, w, h) // CCSceneResolutionPolicy.ShowAll will ensure that the aspect ratio is preserved CCScene.SetDefaultDesignResolution(desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll); CCSimpleAudioEngine.SharedEngine.PreloadEffect("sounds/hit_paddle"); CCSimpleAudioEngine.SharedEngine.PreloadEffect("sounds/hit_wall"); CCSimpleAudioEngine.SharedEngine.PreloadEffect("sounds/hit_off"); var scene = new CCScene(mainWindow); var introLayer = new IntroLayer(); scene.AddChild(introLayer); mainWindow.RunWithScene(scene); }
/// <summary> /// Constructs a new main game scene. /// </summary> /// <param name="window">window to use</param> public MainGameScene(CCWindow window) : base(window) { this.gameLayer = new MainGameLayer(); this.AddChild(this.gameLayer); }
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 desiredHeight = 512.0f; float desiredWidth = 384.0f; // This will set the world bounds to be (0,0, w, h). // CCSceneResolutionPolicy.ShowAll will ensure that the aspect ratio is preserved. CCScene.SetDefaultDesignResolution (desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll); // 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; } CCScene scene = new CCScene (mainWindow); GameLayer gameLayer = new GameLayer (); scene.AddChild (gameLayer); mainWindow.RunWithScene (scene); }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; application.ContentSearchPaths.Add ("fonts"); application.ContentSearchPaths.Add ("landscape"); application.ContentSearchPaths.Add ("menu"); application.ContentSearchPaths.Add ("interface"); application.ContentSearchPaths.Add ("particle"); gameContainer = new mapKnightLibrary.Container (); gameContainer.mainCharacter= new RoboBob(); gameContainer.physicsHandler = new PhysicsHandler (); runningWindow = mainWindow; // This tells the application to not use antialiasing which can // improve the performance of your game. // Get the resolution of the main window... var bounds = mainWindow.WindowSizeInPixels; ////definieren der Windowgröße auf 1280x576 p (16:9) CCScene.SetDefaultDesignResolution (bounds.Width, bounds.Height, CCSceneResolutionPolicy.ShowAll); //startScene = new StartScene (mainWindow); gameScene = new GameScene (mainWindow, gameContainer, RunningControlType); optionScene = new OptionScene (mainWindow); // startet das erste Fenster mainWindow.RunWithScene (gameScene); //startScene.Version = app_version; //startScene.startGame += startGame; //if (ApplicationFinishedLaunching != null) // ApplicationFinishedLaunching (this, EventArgs.Empty); }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { application.ContentRootDirectory = "Content"; var windowSize = mainWindow.WindowSizeInPixels; var desiredWidth = 1024.0f; var desiredHeight = 768.0f; // This will set the world bounds to be (0,0, w, h) // CCSceneResolutionPolicy.ShowAll will ensure that the aspect ratio is preserved mainWindow.SetDesignResolutionSize(desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll); // 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("hd"); CCSprite.DefaultTexelToContentSizeRatio = 2.0f; } else { application.ContentSearchPaths.Add("ld"); CCSprite.DefaultTexelToContentSizeRatio = 1.0f; } var scene = new CCScene(mainWindow); var introLayer = new IntroLayer(); scene.AddChild(introLayer); mainWindow.RunWithScene(scene); }
public GameScene(CCWindow mainWindow) : base(mainWindow) { mainLayer = new CCLayer (); AddChild (mainLayer); paddleSprite = new CCSprite ("paddle"); paddleSprite.PositionX = 100; paddleSprite.PositionY = 100; mainLayer.AddChild (paddleSprite); ballSprite = new CCSprite ("ball"); ballSprite.PositionX = 320; ballSprite.PositionY = 600; mainLayer.AddChild (ballSprite); scoreLabel = new CCLabel ("Score: 0", "arial", 22); scoreLabel.PositionX = mainLayer.VisibleBoundsWorldspace.MinX + 20; scoreLabel.PositionY = mainLayer.VisibleBoundsWorldspace.MaxY - 20; scoreLabel.AnchorPoint = CCPoint.AnchorUpperLeft; mainLayer.AddChild (scoreLabel); Schedule (RunGameLogic); touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesMoved = HandleTouchesMoved; AddEventListener (touchListener, this); }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; try { CCSimpleAudioEngine.SharedEngine.PreloadEffect("Sounds/SplatEffect"); CCSimpleAudioEngine.SharedEngine.PreloadEffect("Sounds/pew-pew-lei"); CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic("Sounds/backgroundSound", true); CCSimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 0.9f; CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.7f; } catch(Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } var winSize = mainWindow.WindowSizeInPixels; mainWindow.SetDesignResolutionSize(winSize.Width, winSize.Height, CCSceneResolutionPolicy.ExactFit); // CCScene.SetDefaultDesignResolution(winSize.Width, winSize.Height, CCSceneResolutionPolicy.ExactFit); // TODO: Set this up when we have a Game Layer CCScene scene = GameStartLayer.GameStartLayerScene(mainWindow); mainWindow.RunWithScene (scene); }
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 StartScene(CCWindow mainWindow) : base(mainWindow) { mainLayer = new CCLayer (); AddChild (mainLayer); PlayButton = new CCSprite ("logo"); NameLabel = new CCLabel ("Map Knight - Alpha", "arial", 22); CreatorLabel = new CCLabel ("Created by tipfom and Exo", "arial", 22); VersionLabel = new CCLabel ("Version unspecified", "arial", 22); InfoLabel = new CCLabel ("Click to play", "arial", 22); PlayButton.ScaleX = mainWindow.WindowSizeInPixels.Width / PlayButton.ContentSize.Width; PlayButton.ScaleY = mainWindow.WindowSizeInPixels.Height / PlayButton.ContentSize.Height; PlayButton.Position = new CCPoint (PlayButton.ScaledContentSize.Width / 2, PlayButton.ScaledContentSize.Height / 2); NameLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, mainWindow.WindowSizeInPixels.Height / 2 - NameLabel.ContentSize.Height); CreatorLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, NameLabel.PositionY - CreatorLabel.ContentSize.Height - 30); VersionLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, CreatorLabel.PositionY - VersionLabel.ContentSize.Height - 30); InfoLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, VersionLabel.PositionY - InfoLabel.ContentSize.Height - 30); mainLayer.AddChild (PlayButton); mainLayer.AddChild (NameLabel); mainLayer.AddChild (CreatorLabel); mainLayer.AddChild (VersionLabel); mainLayer.AddChild (InfoLabel); touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesEnded = HandleTouchesEnded; AddEventListener (touchListener, this); }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { CCLog.Logger = DebugLogging; preferredWidth = 1024; preferredHeight = 768; application.PreferMultiSampling = true; application.ContentRootDirectory = "Content"; //CCSpriteFontCache.FontScale = 0.5f; //CCSpriteFontCache.RegisterFont("MarkerFelt", 22); //CCSpriteFontCache.RegisterFont("arial", 12, 24); CCSize designSize = new CCSize(480, 320); // if (CCDrawManager.FrameSize.Height > 320) // { // //CCSize resourceSize = new CCSize(960, 640); // CCSize resourceSize = new CCSize(480, 320); // application.ContentSearchPaths.Add("hd"); // director.ContentScaleFactor = resourceSize.Height / designSize.Height; // } CCScene.SetDefaultDesignResolution(designSize.Width, designSize.Height, CCSceneResolutionPolicy.ShowAll); // turn on display FPS mainWindow.DisplayStats = true; mainWindow.StatsScale = 2; CCScene pScene = GoblinLayer.Scene(mainWindow); mainWindow.RunWithScene(pScene); }
// Make public once multiple window support added CCWindow AddWindow(CCSize screenSizeInPixels) { CCWindow window = new CCWindow(this, screenSizeInPixels, xnaGame.Window, xnaDeviceManager); gameWindows.Add(window); return(window); }
public GameStartScene(CCWindow mainWindow) : base(mainWindow) { CreateLayer (); addBackgroundLabel (); CreateButton (); }
public static CCScene GameScene(CCWindow mainWindow) { var scene = new CCScene (mainWindow); var layer = new MonsterRun(); scene.AddChild(layer); return scene; }
public static CCScene SceneWithScore (CCWindow mainWindow, int score) { var scene = new CCScene (mainWindow); var layer = new GameOverLayer (score); scene.AddChild (layer); return scene; }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { application.ContentRootDirectory = "Content"; sharedWindow = mainWindow; var introScene = IntroLayer.CreateScene(mainWindow); sharedWindow.RunWithScene(introScene); }
public MergedLayer(CCWindow mainWindow, Container mainContainer) { screenSize = mainWindow.WindowSizeInPixels; gameContainer = mainContainer; mapVersion = "unspecified"; mapCreator = "unspecified"; mapName = "unspecified"; }
public static CCScene GameStartLayerScene (CCWindow mainWindow) { var scene = new CCScene (mainWindow); var layer = new GameStartLayer (); scene.AddChild (layer); return scene; }
void ProcessKeyboard(CCWindow window) { // Read the current keyboard state KeyboardState currentKeyboardState = Keyboard.GetState(); var dispatcher = window.EventDispatcher; if (currentKeyboardState == priorKeyboardState || !dispatcher.IsEventListenersFor(CCEventListenerKeyboard.LISTENER_ID)) { priorKeyboardState = currentKeyboardState; return; } var keyboardEvent = new CCEventKeyboard(CCKeyboardEventType.KEYBOARD_PRESS); var keyboardState = new CCKeyboardState() { KeyboardState = currentKeyboardState }; keyboardEvent.KeyboardState = keyboardState; // Check for pressed/released keys. // Loop for each possible pressed key (those that are pressed this update) Keys[] keys = currentKeyboardState.GetPressedKeys(); for (int k = 0; k < keys.Length; k++) { // Was this key up during the last update? if (priorKeyboardState.IsKeyUp(keys[k])) { // Yes, so this key has been pressed //CCLog.Log("Pressed: " + keys[i].ToString()); keyboardEvent.Keys = (CCKeys)keys[k]; dispatcher.DispatchEvent(keyboardEvent); } } // Loop for each possible released key (those that were pressed last update) keys = priorKeyboardState.GetPressedKeys(); keyboardEvent.KeyboardEventType = CCKeyboardEventType.KEYBOARD_RELEASE; for (int k = 0; k < keys.Length; k++) { // Is this key now up? if (currentKeyboardState.IsKeyUp(keys[k])) { // Yes, so this key has been released //CCLog.Log("Released: " + keys[i].ToString()); keyboardEvent.Keys = (CCKeys)keys[k]; dispatcher.DispatchEvent(keyboardEvent); } } // Store the state for the next loop priorKeyboardState = currentKeyboardState; }
public override void ApplicationDidFinishLaunching (CCApplication application, CCWindow mainWindow) { application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; var bounds = mainWindow.WindowSizeInPixels; CCScene.SetDefaultDesignResolution(bounds.Width, bounds.Height, CCSceneResolutionPolicy.ShowAll); // todo: Add our GameScene initialization here }
/// <summary> /// Initializes a new instance of the <see cref="Client.Common.Views.StartScene"/> class. /// </summary> /// <param name="mainWindow">Main window.</param> public StartScene(CCWindow mainWindow) : base(mainWindow) { Phase = Phases.Start; m_logoLayer = new LogoLayer(this); this.AddChild(m_logoLayer); InitWorld(); }
public GameScene (CCWindow mainWindow) : base(mainWindow) { CreateLayers (); CreateHud (); GoToLevel (LevelManager.Self.CurrentLevel); Schedule(PerformActivity); }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { SharedWindow = mainWindow; DefaultResolution = new CCSize( application.MainWindow.WindowSizeInPixels.Width, application.MainWindow.WindowSizeInPixels.Height); application.ContentRootDirectory = "Content"; CCScene scene = new CCScene(mainWindow); CCLayer layer = new IntroLayer(DefaultResolution); var b = new CozyColorSampleButton(100, 100, 158, 158) { NormalColor = new CCColor4B(255, 0, 0), ClickedColor = new CCColor4B(0, 255, 0), Text = "Hello Bttton", HasBorder = true, }; b.OnClick += () => { }; var list = new CozySampleListView() { ContentSize = new CCSize(350, 350), Orientation = ControlOrientation.Vertical, Position = new CCPoint(100, 100), HasBorder = true, }; layer.AddChild(list); list.AddItem(new CozySampleListViewItemSprite(new CCSprite("gold")) { MarginBottom = 10, MarginTop = 10, HasBorder = true, }); list.AddItem(b); list.AddItem(new CozySampleListViewItemSprite(new CCSprite("gold")) { MarginBottom = 10, MarginTop = 10, HasBorder = true, }); layer.AddEventListener(b.EventListener, layer); scene.AddChild(layer); mainWindow.RunWithScene(scene); }
public static CCScene CreateScene (CCWindow mainWindow) { var scene = new CCScene(mainWindow); var layer = new IntroLayer(); // add layer as a child to scene scene.AddChild(layer); // return the scene return scene; }
public override void ApplicationDidFinishLaunching (CCApplication application, CCWindow mainWindow) { application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; var bounds = mainWindow.WindowSizeInPixels; CCScene.SetDefaultDesignResolution(bounds.Width, bounds.Height, CCSceneResolutionPolicy.ShowAll); GameScene gameScene = new GameScene (mainWindow); mainWindow.RunWithScene (gameScene); }
public SplashScene(CCWindow mainWindow) : base(mainWindow) { splashLayer = new CCLayer (); this.AddChild (splashLayer); splashImage = new CCSprite ("Splash1.png"); splashImage.Position = ContentSize.Center; splashImage.IsAntialiased = false; splashImage.Opacity = 0; }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { //application.AllowUserResizing = true; application.PreferMultiSampling = false; application.ContentRootDirectory = "Content"; application.ContentSearchResolutionOrder = new List<string>() { "", "images", "fonts" }; sharedWindow = mainWindow; CCSize winSize = mainWindow.WindowSizeInPixels; CCScene.SetDefaultDesignResolution(winSize.Width, winSize.Height, CCSceneResolutionPolicy.ShowAll); //CCScene.SetDefaultDesignResolution(winSize.Width/2, winSize.Height/2, 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); mainWindow.DisplayStats = true; mainWindow.StatsScale = 1; // if (mainWindow.WindowSizeInPixels.Height > 320) // { // application.ContentSearchPaths.Insert(0,"HD"); // } //CCApplication.DefaultTexelToContentSizeRatio = 2f; CCScene scene = new CCScene(sharedWindow); CCLayer layer = new TestController(); scene.AddChild(layer); sharedWindow.RunWithScene(scene); }
public LevelSelectScene (CCWindow mainWindow) : base(mainWindow) { CreateLayers (); CreateBackground (); CreateLogo (); CreateLevelButtons (); CreateNavigationButtons (); }
public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { base.ApplicationDidFinishLaunching(application, mainWindow); /** Set up resource folders */ Resources.LoadContent(application); ServerScene = new ServerScene(mainWindow); mainWindow.RunWithScene(ServerScene); LoadAccounts(); ServerScene.Schedule(SaveAccounts, 5); }
public HowToPlayScene (CCWindow mainWindow) : base(mainWindow) { CreateLayer (); CreateBackground (); CreateHowToImage (); CreateHowtoLabel (); CreateBackButton (); }
public CCAccelerometer(CCWindow window) { Window = window; #if !WINDOWS && !OUYA && !NETFX_CORE && !MACOS && !WINDOWSGL try { accelerometer = new Microsoft.Devices.Sensors.Accelerometer(); } catch (Exception ex) { CCLog.Log(ex.ToString()); CCLog.Log("No accelerometer on platform. CCAccelerometer will default to emulation code."); } #endif }
void ProcessGamePad(CCWindow window) { if (window.GamePadEnabled && window.EventDispatcher.IsEventListenersFor(CCEventListenerGamePad.LISTENER_ID)) { // On Android, the gamepad is always connected. GamePadState gps1 = GamePad.GetState(PlayerIndex.One); GamePadState gps2 = GamePad.GetState(PlayerIndex.Two); GamePadState gps3 = GamePad.GetState(PlayerIndex.Three); GamePadState gps4 = GamePad.GetState(PlayerIndex.Four); ProcessGamePad(window, gps1, PlayerIndex.One); ProcessGamePad(window, gps2, PlayerIndex.Two); ProcessGamePad(window, gps3, PlayerIndex.Three); ProcessGamePad(window, gps4, PlayerIndex.Four); } }
public void Draw(CCWindow window) { if (isEnabled) { totalFrames++; totalDrawCount++; totalDrawTime += (float)stopwatch.Elapsed.TotalMilliseconds - startTime; if (isCheckGC && !gcWeakRef.IsAlive) { gcCounter++; gcWeakRef = new WeakReference(new object()); } if (isInitialized) { if (deltaAll > CCMacros.CCDirectorStatsUpdateIntervalInSeconds) { fpsLabel.Text = (String.Format("{0:00.0}", totalDrawCount / deltaAll)); updateTimeLabel.Text = (String.Format("{0:0.000}", totalUpdateTime / updateCount)); drawTimeLabel.Text = (String.Format("{0:0.000}", totalDrawTime / totalDrawCount)); drawCallLabel.Text = (String.Format("{0:000}", window.DrawManager.DrawCount)); deltaAll = totalDrawTime = totalUpdateTime = 0; totalDrawCount = updateCount = 0; memoryLabel.Text = String.Format("{0}", GC.GetTotalMemory(false)); gcLabel.Text = String.Format("{0}", gcCounter); } var scene = window.DefaultDirector.RunningScene; drawCallLabel.Scene = scene; fpsLabel.Scene = scene; updateTimeLabel.Scene = scene; drawTimeLabel.Scene = scene; memoryLabel.Scene = scene; gcLabel.Scene = scene; drawCallLabel.Visit(); fpsLabel.Visit(); updateTimeLabel.Visit(); drawTimeLabel.Visit(); memoryLabel.Visit(); gcLabel.Visit(); } } }
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 CCAccelerometer(CCWindow window) { Window = window; #if IOS accelerometer = new CoreMotion.CMMotionManager(); //accelerometer.AccelerometerUpdateInterval = 60f; #elif !WINDOWS && !OUYA && !NETFX_CORE && !MACOS && !WINDOWSGL && !WINDOWSDX try { accelerometer = new Accelerometer(); } catch (Exception ex) { CCLog.Log(ex.ToString()); CCLog.Log("No accelerometer on platform. CCAccelerometer will default to emulation code."); } #elif NETFX_CORE accelerometer = Accelerometer.GetDefault(); #endif }
void ProcessMouse(CCWindow window) { // Read the current Mouse state MouseState currentMouseState = Mouse.GetState(); var dispatcher = window.EventDispatcher; if (currentMouseState == priorMouseState || !dispatcher.IsEventListenersFor(CCEventListenerMouse.LISTENER_ID)) { priorMouseState = currentMouseState; return; } CCPoint pos; #if NETFX_CORE //Because MonoGame and CocosSharp uses different Y axis, we need to convert the coordinate here pos = TransformPoint(priorMouseState.X, Game.Window.ClientBounds.Height - priorMouseState.Y); #else //Because MonoGame and CocosSharp uses different Y axis, we need to convert the coordinate here pos = new CCPoint(priorMouseState.X, Game.Window.ClientBounds.Height - priorMouseState.Y); #endif var mouseEvent = new CCEventMouse(CCMouseEventType.MOUSE_MOVE); mouseEvent.CursorX = pos.X; mouseEvent.CursorY = pos.Y; dispatcher.DispatchEvent(mouseEvent); CCMouseButton mouseButton = CCMouseButton.None; if (priorMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.LeftButton; } if (priorMouseState.RightButton == ButtonState.Released && currentMouseState.RightButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.RightButton; } if (priorMouseState.MiddleButton == ButtonState.Released && currentMouseState.MiddleButton == ButtonState.Pressed) { mouseButton |= CCMouseButton.MiddleButton; } if (priorMouseState.XButton1 == ButtonState.Released && currentMouseState.XButton1 == ButtonState.Pressed) { mouseButton |= CCMouseButton.ExtraButton1; } if (priorMouseState.XButton2 == ButtonState.Released && currentMouseState.XButton2 == ButtonState.Pressed) { mouseButton |= CCMouseButton.ExtraButton1; } if (mouseButton > 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_DOWN; mouseEvent.MouseButton = mouseButton; dispatcher.DispatchEvent(mouseEvent); } mouseButton = CCMouseButton.None; if (priorMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released) { mouseButton |= CCMouseButton.LeftButton; } if (priorMouseState.RightButton == ButtonState.Pressed && currentMouseState.RightButton == ButtonState.Released) { mouseButton |= CCMouseButton.RightButton; } if (priorMouseState.MiddleButton == ButtonState.Pressed && currentMouseState.MiddleButton == ButtonState.Released) { mouseButton |= CCMouseButton.MiddleButton; } if (priorMouseState.XButton1 == ButtonState.Pressed && currentMouseState.XButton1 == ButtonState.Released) { mouseButton |= CCMouseButton.ExtraButton1; } if (priorMouseState.XButton2 == ButtonState.Pressed && currentMouseState.XButton2 == ButtonState.Released) { mouseButton |= CCMouseButton.ExtraButton1; } if (mouseButton > 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_UP; mouseEvent.MouseButton = mouseButton; dispatcher.DispatchEvent(mouseEvent); } if (priorMouseState.ScrollWheelValue != currentMouseState.ScrollWheelValue) { var delta = priorMouseState.ScrollWheelValue - currentMouseState.ScrollWheelValue; if (delta != 0) { mouseEvent.MouseEventType = CCMouseEventType.MOUSE_SCROLL; mouseEvent.ScrollX = 0; mouseEvent.ScrollY = delta; dispatcher.DispatchEvent(mouseEvent); //Console.WriteLine ("mouse scroll: " + mouseEvent.ScrollY); } } // Store the state for the next loop priorMouseState = currentMouseState; }
public CCScene(CCWindow window) : this(window, window.DefaultDirector) #endif { }
public CCScene(CCWindow window, bool physics = false) : this(window, window.DefaultDirector, physics)
void ProcessGamePad(CCWindow window, GamePadState gps, PlayerIndex player) { var dispatcher = window.EventDispatcher; var lastState = new GamePadState(); if (!priorGamePadState.ContainsKey(player) && gps.IsConnected) { gamePadConnection.IsConnected = true; gamePadConnection.Player = (CCPlayerIndex)player; dispatcher.DispatchEvent(gamePadConnection); } if (priorGamePadState.ContainsKey(player)) { lastState = priorGamePadState[player]; // Notify listeners when the gamepad is connected/disconnected. if ((lastState.IsConnected != gps.IsConnected)) { gamePadConnection.IsConnected = false; gamePadConnection.Player = (CCPlayerIndex)player; dispatcher.DispatchEvent(gamePadConnection); } // TODO: Check button pressed/released status for button tap events. } if (gps.IsConnected) { var caps = GamePad.GetCapabilities(player); if (caps.HasBackButton || caps.HasStartButton || caps.HasBigButton || caps.HasAButton || caps.HasBButton || caps.HasXButton || caps.HasYButton || caps.HasLeftShoulderButton || caps.HasRightShoulderButton) { var back = CCGamePadButtonStatus.NotApplicable; var start = CCGamePadButtonStatus.NotApplicable; var system = CCGamePadButtonStatus.NotApplicable; var a = CCGamePadButtonStatus.NotApplicable; var b = CCGamePadButtonStatus.NotApplicable; var x = CCGamePadButtonStatus.NotApplicable; var y = CCGamePadButtonStatus.NotApplicable; var leftShoulder = CCGamePadButtonStatus.NotApplicable; var rightShoulder = CCGamePadButtonStatus.NotApplicable; if (caps.HasBackButton) { back = (gps.Buttons.Back == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasStartButton) { start = (gps.Buttons.Start == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasBigButton) { system = (gps.Buttons.BigButton == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasAButton) { a = (gps.Buttons.A == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasBButton) { b = (gps.Buttons.B == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasXButton) { x = (gps.Buttons.X == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasYButton) { y = (gps.Buttons.Y == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasLeftShoulderButton) { leftShoulder = (gps.Buttons.LeftShoulder == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasRightShoulderButton) { rightShoulder = (gps.Buttons.RightShoulder == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } gamePadButton.Back = back; gamePadButton.Start = start; gamePadButton.System = system; gamePadButton.A = a; gamePadButton.B = b; gamePadButton.X = x; gamePadButton.Y = y; gamePadButton.LeftShoulder = leftShoulder; gamePadButton.RightShoulder = rightShoulder; gamePadButton.Player = (CCPlayerIndex)player; dispatcher.DispatchEvent(gamePadButton); } // Process the game sticks if ((caps.HasLeftXThumbStick || caps.HasLeftYThumbStick || caps.HasRightXThumbStick || caps.HasRightYThumbStick || caps.HasLeftStickButton || caps.HasRightStickButton)) { CCPoint vecLeft; if (caps.HasLeftXThumbStick || caps.HasLeftYThumbStick) { vecLeft = new CCPoint(gps.ThumbSticks.Left); vecLeft.Normalize(); } else { vecLeft = CCPoint.Zero; } CCPoint vecRight; if (caps.HasRightXThumbStick || caps.HasRightYThumbStick) { vecRight = new CCPoint(gps.ThumbSticks.Right); vecRight.Normalize(); } else { vecRight = CCPoint.Zero; } var left = new CCGameStickStatus(); left.Direction = vecLeft; left.Magnitude = ((caps.HasLeftXThumbStick || caps.HasLeftYThumbStick) ? gps.ThumbSticks.Left.Length() : 0f); left.IsDown = ((caps.HasLeftStickButton) ? gps.IsButtonDown(Buttons.LeftStick) : false); var right = new CCGameStickStatus(); right.Direction = vecRight; right.Magnitude = ((caps.HasRightXThumbStick || caps.HasRightYThumbStick) ? gps.ThumbSticks.Right.Length() : 0f); right.IsDown = ((caps.HasLeftStickButton) ? gps.IsButtonDown(Buttons.RightStick) : false); gamePadStick.Left = left; gamePadStick.Right = right; gamePadStick.Player = (CCPlayerIndex)player; dispatcher.DispatchEvent(gamePadStick); } // Process the game triggers if (caps.HasLeftTrigger || caps.HasRightTrigger) { //GamePadTriggerUpdate (caps.HasLeftTrigger ? gps.Triggers.Left : 0f, caps.HasRightTrigger ? gps.Triggers.Right : 0f, player); gamePadTrigger.Left = caps.HasLeftTrigger ? gps.Triggers.Left : 0f; gamePadTrigger.Right = caps.HasRightTrigger ? gps.Triggers.Right : 0f; gamePadTrigger.Player = (CCPlayerIndex)player; dispatcher.DispatchEvent(gamePadTrigger); } // Process the D-Pad if (caps.HasDPadDownButton || caps.HasDPadUpButton || caps.HasDPadLeftButton || caps.HasDPadRightButton) { var leftButton = CCGamePadButtonStatus.NotApplicable; var rightButton = CCGamePadButtonStatus.NotApplicable; var upButton = CCGamePadButtonStatus.NotApplicable; var downButton = CCGamePadButtonStatus.NotApplicable; if (caps.HasDPadDownButton) { downButton = (gps.DPad.Down == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasDPadUpButton) { upButton = (gps.DPad.Up == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasDPadLeftButton) { leftButton = (gps.DPad.Left == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasDPadRightButton) { rightButton = (gps.DPad.Right == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } gamePadDPad.Down = downButton; gamePadDPad.Up = upButton; gamePadDPad.Left = leftButton; gamePadDPad.Right = rightButton; gamePadDPad.Player = (CCPlayerIndex)player; dispatcher.DispatchEvent(gamePadDPad); } } priorGamePadState[player] = gps; }
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, bool physics = false)
void RemoveWindow(CCWindow window) { // TBA once multiple window support added }
public virtual void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) { }
public CCScene(CCWindow window, CCDirector director) : this(window, new CCViewport(new CCRect(0.0f, 0.0f, 1.0f, 1.0f)), director) #endif { }
void ProcessTouch(CCWindow window) { if (window.EventDispatcher.IsEventListenersFor(CCEventListenerTouchOneByOne.LISTENER_ID) || window.EventDispatcher.IsEventListenersFor(CCEventListenerTouchAllAtOnce.LISTENER_ID)) { newTouches.Clear(); movedTouches.Clear(); endedTouches.Clear(); CCPoint pos = CCPoint.Zero; // TODO: allow configuration to treat the game pad as a touch device. #if WINDOWS || WINDOWSGL || MACOS pos = new CCPoint(lastMouseState.X, lastMouseState.Y); prevMouseState = lastMouseState; lastMouseState = Mouse.GetState(); if (prevMouseState.LeftButton == ButtonState.Released && lastMouseState.LeftButton == ButtonState.Pressed) { lastMouseId++; touches.AddLast(new CCTouch(lastMouseId, pos.X, pos.Y)); touchMap.Add(lastMouseId, touches.Last); newTouches.Add(touches.Last.Value); } else if (prevMouseState.LeftButton == ButtonState.Pressed && lastMouseState.LeftButton == ButtonState.Pressed) { if (touchMap.ContainsKey(lastMouseId)) { if (prevMouseState.X != lastMouseState.X || prevMouseState.Y != lastMouseState.Y) { movedTouches.Add(touchMap[lastMouseId].Value); touchMap[lastMouseId].Value.SetTouchInfo(lastMouseId, pos.X, pos.Y); } } } else if (prevMouseState.LeftButton == ButtonState.Pressed && lastMouseState.LeftButton == ButtonState.Released) { if (touchMap.ContainsKey(lastMouseId)) { endedTouches.Add(touchMap[lastMouseId].Value); touches.Remove(touchMap[lastMouseId]); touchMap.Remove(lastMouseId); } } #endif TouchCollection touchCollection = TouchPanel.GetState(); foreach (TouchLocation touch in touchCollection) { switch (touch.State) { case TouchLocationState.Pressed: if (touchMap.ContainsKey(touch.Id)) { break; } pos = new CCPoint(touch.Position.X, touch.Position.Y); touches.AddLast(new CCTouch(touch.Id, pos.X, pos.Y)); touchMap.Add(touch.Id, touches.Last); newTouches.Add(touches.Last.Value); break; case TouchLocationState.Moved: LinkedListNode <CCTouch> existingTouch; if (touchMap.TryGetValue(touch.Id, out existingTouch)) { pos = new CCPoint(touch.Position.X, touch.Position.Y); var delta = existingTouch.Value.LocationOnScreen - pos; if (delta.LengthSquared > 1.0f) { movedTouches.Add(existingTouch.Value); existingTouch.Value.SetTouchInfo(touch.Id, pos.X, pos.Y); } } break; case TouchLocationState.Released: if (touchMap.TryGetValue(touch.Id, out existingTouch)) { endedTouches.Add(existingTouch.Value); touches.Remove(existingTouch); touchMap.Remove(touch.Id); } break; default: throw new ArgumentOutOfRangeException(); } } var touchEvent = new CCEventTouch(CCEventCode.BEGAN); if (newTouches.Count > 0) { touchEvent.Touches = newTouches; //m_pDelegate.TouchesBegan(newTouches); window.EventDispatcher.DispatchEvent(touchEvent); } if (movedTouches.Count > 0) { touchEvent.EventCode = CCEventCode.MOVED; touchEvent.Touches = movedTouches; window.EventDispatcher.DispatchEvent(touchEvent); } if (endedTouches.Count > 0) { touchEvent.EventCode = CCEventCode.ENDED; touchEvent.Touches = endedTouches; window.EventDispatcher.DispatchEvent(touchEvent); } } }