void LoadGame(object sender, EventArgs e) { var nativeGameView = sender as CCGameView; if (nativeGameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds" }; CCSizeI viewSize = nativeGameView.ViewSize; CCSizeI designResolution = nativeGameView.DesignResolution; _gameView.DesignResolution = new Size(viewSize.Width, viewSize.Height); nativeGameView.ContentManager.SearchPaths = contentSearchPaths; //create a scrollview with the correct viewsize and an area to move in the size of 3000 by 3000 var scrollView = new ScrollViewInAction(nativeGameView.ViewSize); scrollView.BouncingRectSize = new CCSize(3000, 3000); var scrollLayer = new CCLayerColor(CCColor4B.White); scrollLayer.AddChild(scrollView); CCScene gameScene = new CCScene(nativeGameView); gameScene.AddLayer(scrollLayer); nativeGameView.RunWithScene(gameScene); } }
void LoadGame(object sender, EventArgs e) { m_GameView = sender as CCGameView; if (m_GameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds", "Images" }; CCSizeI viewSize = m_GameView.ViewSize; int width = 1920; int height = 1080; // Set world dimensions m_GameView.DesignResolution = new CCSizeI(width, height); m_GameView.ContentManager.SearchPaths = contentSearchPaths; SwitchToMenu(SceneIds.OpeningMenu, 0); CCAudioEngine.SharedEngine.PlayBackgroundMusic(filename: "mix_6m07s", loop: true); } }
//Set from settings public GameLayer(CCSizeI size) : base(CCColor4B.Black) { // create and initialize a Label labelScore = new CCLabel(string.Format("SCORE: {0}", _score), "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); //labelScore.VerticalAlignment = CCVerticalTextAlignment.Top; labelLives = new CCLabel(string.Format("LIVES: {0}", _lives), "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); //CRect rect = new CCRect(50, 50, 200, 200); //CCDrawNode tile = new CCDrawNode(); //var color = new CCColor4F(255, 216, 0, 0.5f); //tile.DrawRect(rect, new CCColor4F(color)); //CCRect rect2 = new CCRect(50, 50 + 200, 200, 200); //CCDrawNode tile2 = new CCDrawNode(); //tile.DrawRect(rect2, CCColor4B.Red); // add the label as a child to this Layer //int i = 0; AddChild(labelScore); AddChild(labelLives); InitProgressTimer(size); InitSquares(); }
void LoadGame(object sender, EventArgs e) { var nativeGameView = sender as CCGameView; if (nativeGameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds" }; CCSizeI viewSize = nativeGameView.ViewSize; CCSizeI designResolution = nativeGameView.DesignResolution; // 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 (designResolution.Width < viewSize.Width) { contentSearchPaths.Add("Images/Hd"); CCSprite.DefaultTexelToContentSizeRatio = 2.0f; } else { contentSearchPaths.Add("Images/Ld"); CCSprite.DefaultTexelToContentSizeRatio = 1.0f; } nativeGameView.ContentManager.SearchPaths = contentSearchPaths; CCScene gameScene = new CCScene(nativeGameView); gameScene.AddLayer(new GameLayer(designResolution)); nativeGameView.RunWithScene(gameScene); } }
public static void Initialize(CCGameView gameView) { GameView = gameView; var contentSearchPaths = new List <string> () { "Fonts", "Sounds" }; CCSizeI viewSize = GameView.ViewSize; int width = 768; int height = 1024; // Set world dimensions GameView.DesignResolution = new CCSizeI(width, height); // 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) CCSprite.DefaultTexelToContentSizeRatio = 0.5f; contentSearchPaths.Add("Images"); GameView.ContentManager.SearchPaths = contentSearchPaths; var scene = new TitleScene(GameView); GameView.Director.RunWithScene(scene); }
void LoadGame(object sender, EventArgs e) { var nativeGameView = sender as CCGameView; if (nativeGameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds" }; CCSizeI viewSize = nativeGameView.ViewSize; CCSizeI designResolution = nativeGameView.DesignResolution; nativeGameView.ResolutionPolicy = CCViewResolutionPolicy.NoBorder; contentSearchPaths.Add("Images"); CCAudioEngine.SharedEngine.PreloadEffect("Sounds/coin"); CCAudioEngine.SharedEngine.PreloadEffect("Sounds/explosion"); CCAudioEngine.SharedEngine.PreloadEffect("Sounds/jump"); CCAudioEngine.SharedEngine.PreloadBackgroundMusic("Sounds/Alpha Dance"); CCAudioEngine.SharedEngine.BackgroundMusicVolume = 0.5f; nativeGameView.ContentManager.SearchPaths = contentSearchPaths; CCScene gameScene = new CCScene(nativeGameView); gameScene.AddLayer(new GameTitleLayer()); nativeGameView.RunWithScene(gameScene); } }
private void InitProgressTimer(CCSizeI size) { _progressTimer = new CCProgressTimer("bluePx.png"); _progressTimer.Type = CCProgressTimerType.Bar; _progressTimer.ScaleX = size.Width - 20; _progressTimer.ScaleY = 4; //_progressTimer.AnchorPoint = new CCPoint(1.0f, 0.5f); _progressTimer.Percentage = 100.0f; _progressTimer.BarChangeRate = new CCPoint(1, 0); AddChild(_progressTimer); }
//CCGameView nativeGameView; void LoadGame(object sender, EventArgs e) { var nativeGameView = sender as CCGameView; if (nativeGameView != null) { //var contentSearchPaths = new List<string>() { "Fonts"}; CCSizeI viewSize = nativeGameView.ViewSize; CCSizeI designResolution = nativeGameView.DesignResolution; CCAudioEngine.SharedEngine.PreloadEffect(Sounds.PressSuccess); CCAudioEngine.SharedEngine.PreloadEffect(Sounds.PressFail); CCAudioEngine.SharedEngine.PreloadEffect(Sounds.LevelRise); CCAudioEngine.SharedEngine.PreloadEffect(Sounds.GameOver); CCAudioEngine.SharedEngine.PreloadEffect(Sounds.GainPoint); // 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 (designResolution.Width < viewSize.Width) //{ // contentSearchPaths.Add("Images/Hd"); // CCSprite.DefaultTexelToContentSizeRatio = 2.0f; //} //else //{ // contentSearchPaths.Add("Images/Ld"); // CCSprite.DefaultTexelToContentSizeRatio = 1.0f; //} //nativeGameView.ContentManager.SearchPaths = contentSearchPaths; CCScene gameScene = new CCScene(nativeGameView); GameLayer gameLayer = null; var backcolor = Settings.IsDarkTheme ? new CCColor4B(48, 48, 48) : CCColor4B.White; if (_navigationService.GameTypeSelected == Enums.GameType.NormalGame) { gameLayer = new NormalGameLayer(designResolution, backcolor); } else { gameLayer = new ArcadeGameLayer(designResolution, backcolor); } gameLayer.OnGameIsOver = GameOver; gameScene.AddLayer(gameLayer); nativeGameView.RunWithScene(gameScene); } }
void LoadGame(object sender, EventArgs e) { CCGameView gameView = sender as CCGameView; List <object> iOSProperties = new List <object>(); currentMod = (String.IsNullOrWhiteSpace(userDefaults.StringForKey("CurrentMod")) ? "Original" : userDefaults.StringForKey("CurrentMod")); iOSProperties.Add(View.Window.Frame.Width); iOSProperties.Add(View.Window.Frame.Height); iOSProperties.Add(forceTouchAvailable); iOSProperties.Add((Action <string>)ControlMenu); iOSProperties.Add((Action <bool, string, string, float>)ControlSound); iOSProperties.Add((Func <string, string>)userDefaults.StringForKey); iOSProperties.Add((Action <string, string>)userDefaults.SetString); iOSProperties.Add((Action)ShowBestTimeAlert); if (gameView != null) { CCScene gameScene; CCSizeI viewSize = gameView.ViewSize; var contentSearchPaths = new List <string>() { "Fonts", "Images/" + currentMod, "Sounds/" + currentMod }; // Set world dimensions. gameView.DesignResolution = new CCSizeI((int)View.Window.Frame.Width, (int)View.Window.Frame.Height); // 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 (viewSize.Width < (int)View.Window.Frame.Width) { CCSprite.DefaultTexelToContentSizeRatio = 1.0f; } else { CCSprite.DefaultTexelToContentSizeRatio = 2.0f; } gameView.ContentManager.SearchPaths = contentSearchPaths; gameScene = new CCScene(gameView); gameLayer = new GameLayer(APP_NAME, iOSProperties, new List <object>()); // Compensate for a bug with CocosSharp GameScene scaling that leaves a white line at the top. gameScene.ScaleY = 1.0001f; AddMenu(); gameScene.AddLayer(gameLayer); gameView.RunWithScene(gameScene); } }
public ArcadeGameLayer(CCSizeI size, CCColor4B backcolor) : base(size, backcolor) { labelScore = new CCLabel(string.Format("SCORE: {0}", _score), "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); labelScore.Color = new CCColor3B(27, 161, 226); InitNewGameComponents(); AddChild(labelScore); labelGameMode = new CCLabel(_gameModeText, "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); labelGameMode.Color = new CCColor3B(68, 14, 98); AddChild(labelGameMode); labelGameMode.Text = _gameModeText.ToUpper(); }
private void InitProgressTimer(CCSizeI size) { _progressTimer = new CCProgressTimer(new CCSprite(bluePx)); _progressTimer.Type = CCProgressTimerType.Bar; // _progressTimer.SkewX //_progressTimer.ContentSize = new CCSize(size.Width, 8); _progressTimer.Midpoint = new CCPoint(0.5f, 0.5f); _progressTimer.ScaleY = 2; //Device.OnPlatform(null, Android: () => { _progressTimer.ScaleY = 4; _progressTimer.ScaleX = 2; }); //_progressTimer.ScaleX = size.Width - 40; //_progressTimer.ScaleY = 4; //_progressTimer.AnchorPoint = new CCPoint(1.0f, 0.5f); //_progressTimer.Percentage = 100.0f; _progressTimer.BarChangeRate = new CCPoint(1, 0); AddChild(_progressTimer); }
void LoadGame(object sender, EventArgs e) { CCGameView gameView = sender as CCGameView; if (gameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds" }; CCSizeI viewSize = gameView.ViewSize; int width = 1024; int height = 768; // // Set world dimensions gameView.DesignResolution = new CCSizeI(gameView.Width, gameView.Height); gm = new GameLayer(); // gm.mymethod(gameView.Width, gameView.Height); // 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 (width < viewSize.Width) { contentSearchPaths.Add("Images/Hd"); CCSprite.DefaultTexelToContentSizeRatio = 2.0f; } else { contentSearchPaths.Add("Images/Ld"); CCSprite.DefaultTexelToContentSizeRatio = 1.0f; } gameView.ContentManager.SearchPaths = contentSearchPaths; CCScene gameScene = new CCScene(gameView); gameScene.AddLayer(new GameLayer()); gameView.RunWithScene(gameScene); } }
public static void LoadGame(object sender, EventArgs e) { GameView = sender as CCGameView; if (GameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds" }; CCSizeI viewSize = GameView.ViewSize; int width = 1024; int height = 768; // Set world dimensions GameView.DesignResolution = new CCSizeI(width, height); GameView.ResolutionPolicy = CCViewResolutionPolicy.ExactFit; // 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 (width < viewSize.Width) { //contentSearchPaths.Add("Images/Collision"); CCSprite.DefaultTexelToContentSizeRatio = 2.0f; } else { //contentSearchPaths.Add("Images/Periphery"); CCSprite.DefaultTexelToContentSizeRatio = 1.0f; } GameView.ContentManager.SearchPaths = contentSearchPaths; var gameScene = new GameScene(GameView); GameView.RunWithScene(gameScene); } }
void LoadGame(object sender, EventArgs e) { CCGameView gameView = sender as CCGameView; if (gameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds", "Images/Animals" }; CCSizeI viewSize = gameView.ViewSize; int width = 960; int height = 540; // Set world dimensions gameView.DesignResolution = new CCSizeI(width, height); gameView.ResolutionPolicy = CCViewResolutionPolicy.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 (width < viewSize.Width) { contentSearchPaths.Add("Images/Hd"); //CCSprite.DefaultTexelToContentSizeRatio = 2.0f; } else { contentSearchPaths.Add("Images/Ld"); CCSprite.DefaultTexelToContentSizeRatio = 1.0f; } gameView.ContentManager.SearchPaths = contentSearchPaths; PlayBackgroundMusic(); // Construct game scene _gameView = gameView; RunMenu(); } }
void LoadGame(object sender, EventArgs e) { var nativeGameView = sender as CCGameView; if (nativeGameView != null) { var contentSearchPaths = new List <string>() { "Fonts" }; int width = nativeGameView.DesignResolution.Width; int height = nativeGameView.DesignResolution.Height; CCSizeI viewSize = nativeGameView.ViewSize; CCSizeI designResolution = nativeGameView.DesignResolution; // 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 (designResolution.Width < viewSize.Width) * { * contentSearchPaths.Add("Images/Hd"); * CCSprite.DefaultTexelToContentSizeRatio = 2.0f; * } * else * { * contentSearchPaths.Add("Images/Ld"); * CCSprite.DefaultTexelToContentSizeRatio = 1.0f; * } */ nativeGameView.ContentManager.SearchPaths = contentSearchPaths; nativeGameView.RunWithScene(new GameStartScene(nativeGameView, width, height, this)); ConstructGameScene(nativeGameView); } }
public static void LoadGame(object sender, EventArgs e) { CCGameView gameView = sender as CCGameView; if (gameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds" }; CCSizeI viewSize = gameView.ViewSize; // Set world dimensions gameView.DesignResolution = new CCSizeI(viewSize.Width, viewSize.Height); // 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 (width < viewSize.Width) //{ // contentSearchPaths.Add("Images/Hd"); // CCSprite.DefaultTexelToContentSizeRatio = 2.0f; //} //else //{ contentSearchPaths.Add("Images/Ld"); CCSprite.DefaultTexelToContentSizeRatio = 1.0f; //} gameView.ContentManager.SearchPaths = contentSearchPaths; CCAudioEngine.SharedEngine.PreloadEffect("pop"); CCScene gameScene = new CCScene(gameView); gameScene.AddLayer(new MenuLayer()); gameView.RunWithScene(gameScene); } }
void LoadGame(object sender, EventArgs e) { CCGameView gameView = sender as CCGameView; if (gameView != null) { var contentSearchPaths = new List <string>() { "Fonts", "Sounds" }; CCSizeI viewSize = gameView.ViewSize; Display display = WindowManager.DefaultDisplay; Point Size = new Point(); display.GetSize(Size); int width = Size.X - 1; int height = Size.Y - 1; gameView.DesignResolution = new CCSizeI(width, height); if (width < viewSize.Width) { contentSearchPaths.Add("Images/Hd"); CCSprite.DefaultTexelToContentSizeRatio = 2.0f; } else { contentSearchPaths.Add("Images/Ld"); CCSprite.DefaultTexelToContentSizeRatio = 1.0f; } gameView.ContentManager.SearchPaths = contentSearchPaths; CCScene gameScene = new CCScene(gameView); gameScene.AddLayer(new GameLayer(this, width, height, IntentType, NrTel, GameId)); gameView.RunWithScene(gameScene); } }
public GameLayer(CCSizeI size, CCColor4B backcolor) : base(backcolor) { // _gameType = gameTipe; // create and initialize a Label //labelScore.VerticalAlignment = CCVerticalTextAlignment.Top; //CRect rect = new CCRect(50, 50, 200, 200); //CCDrawNode tile = new CCDrawNode(); //var color = new CCColor4F(255, 216, 0, 0.5f); //tile.DrawRect(rect, new CCColor4F(color)); //CCRect rect2 = new CCRect(50, 50 + 200, 200, 200); //CCDrawNode tile2 = new CCDrawNode(); //tile.DrawRect(rect2, CCColor4B.Red); // add the label as a child to this Layer //int i = 0; InitProgressTimer(size); InitSquares(); _soundButton = new Sound(); AddChild(_soundButton); _pauseButton = new Pause(); AddChild(_pauseButton); //InitNewGameComponents(); _pauseButton.OnTapped = OnPausePressed; }
public NormalGameLayer(CCSizeI size, CCColor4B backcolor) : base(size, backcolor) { //labelLives = new CCLabel(string.Format("LIVES: {0}", _lives), "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); //labelLives.Color = new CCColor3B(27, 161, 226); //labelLevel = new CCLabel(string.Format("LEVEL: {0}", _score), "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); //labelLevel.Color = new CCColor3B(27, 161, 226); //AddChild(labelLives); //AddChild(labelLevel); labelScore = new CCLabel(string.Format("SCORE: {0}", _score), "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); labelScore.Color = new CCColor3B(27, 161, 226); AddChild(labelScore); levelLabel = new CCSprite(level); AddChild(levelLabel); livesLabel = new CCSprite(lives); AddChild(livesLabel); levelSquares = new Dictionary <LevelLivePosition, CCSprite>(); livesSquares = new Dictionary <LevelLivePosition, CCSprite>(); levelSquares[LevelLivePosition.One] = new CCSprite(green40x40) { Visible = true }; levelSquares[LevelLivePosition.Two] = new CCSprite(green40x40) { Visible = false }; levelSquares[LevelLivePosition.Three] = new CCSprite(green40x40) { Visible = false }; levelSquares[LevelLivePosition.Four] = new CCSprite(blue40x40) { Visible = false }; levelSquares[LevelLivePosition.Five] = new CCSprite(blue40x40) { Visible = false }; levelSquares[LevelLivePosition.Six] = new CCSprite(yellow40x40) { Visible = false }; levelSquares[LevelLivePosition.Seven] = new CCSprite(yellow40x40) { Visible = false }; levelSquares[LevelLivePosition.Eight] = new CCSprite(red40x40) { Visible = false }; levelSquares[LevelLivePosition.Nine] = new CCSprite(red40x40) { Visible = false }; levelSquares[LevelLivePosition.Ten] = new CCSprite(red40x40) { Visible = false }; levelSquares[LevelLivePosition.Eleven] = new CCSprite(red40x40) { Visible = false }; levelSquares[LevelLivePosition.Twelve] = new CCSprite(red40x40) { Visible = false }; levelSquares[LevelLivePosition.Thirteen] = new CCSprite(red40x40) { Visible = false }; levelSquares[LevelLivePosition.Plus] = new CCSprite(redplus) { Visible = false }; livesSquares[LevelLivePosition.One] = new CCSprite(red40x40) { Visible = true }; livesSquares[LevelLivePosition.Two] = new CCSprite(red40x40) { Visible = true }; livesSquares[LevelLivePosition.Three] = new CCSprite(red40x40) { Visible = true }; livesSquares[LevelLivePosition.Four] = new CCSprite(yellow40x40) { Visible = false }; livesSquares[LevelLivePosition.Five] = new CCSprite(yellow40x40) { Visible = false }; livesSquares[LevelLivePosition.Six] = new CCSprite(blue40x40) { Visible = false }; livesSquares[LevelLivePosition.Seven] = new CCSprite(blue40x40) { Visible = false }; livesSquares[LevelLivePosition.Eight] = new CCSprite(green40x40) { Visible = false }; livesSquares[LevelLivePosition.Nine] = new CCSprite(green40x40) { Visible = false }; livesSquares[LevelLivePosition.Ten] = new CCSprite(green40x40) { Visible = false }; livesSquares[LevelLivePosition.Eleven] = new CCSprite(green40x40) { Visible = false }; livesSquares[LevelLivePosition.Twelve] = new CCSprite(green40x40) { Visible = false }; livesSquares[LevelLivePosition.Thirteen] = new CCSprite(green40x40) { Visible = false }; livesSquares[LevelLivePosition.Plus] = new CCSprite(greenplus) { Visible = false }; foreach (var item in levelSquares.Values) { AddChild(item); } foreach (var item in livesSquares.Values) { AddChild(item); } InitNewGameComponents(); labelGameMode = new CCLabel(_gameModeText, "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); labelGameMode.Color = new CCColor3B(68, 14, 98); AddChild(labelGameMode); labelGameMode.Text = _gameModeText.ToUpper(); }