public virtual SpriteTile createSprite(TextureInfo texture_info, float world_scale=1.5f) { SpriteTile sprite; //スプライト生成 sprite = new SpriteTile(){TextureInfo = texture_info}; //表示するテクスチャID sprite.TileIndex1D=0; //拡大率 sprite.Quad.S = sprite.CalcSizeInPixels() * world_scale; //スプライトの中心と座標の中心を一致させる sprite.CenterSprite(); //輝度設定 sprite.Color=new Vector4(1.0f,1.0f,1.0f,1.00f); //表示の混合設定 sprite.BlendMode = BlendMode.Normal; return sprite; }
// public BetterButton (float pWidth, float pHeight, Font pFont) { // _textFont = pFont; // Initialize(pWidth, pHeight); // } // // public BetterButton( string pBackgroundPath, Font pFont) { // _textFont = pFont; // background = Support.TiledSpriteFromFile(pBackgroundPath, 1, 3); // var size = background.CalcSizeInPixels(); // Initialize(size.X, size.Y); // } /// <summary> /// Initializes a new instance of the <see cref="Crystallography.UI.BetterButton"/> class that uses a specific background image. /// </summary> /// <param name='pBackgroundPath'> /// P background path. /// </param> public BetterButton(string pBackgroundPath) { background = Support.TiledSpriteFromFile(pBackgroundPath, 1, 3); var size = background.CalcSizeInPixels(); Initialize(size.X, size.Y); }
// CONSTRUCTOR -------------------------------------------------------------------------------------------------------------------------------------- public InfiniteModeEndPanel() { DismissDelay = 0.0f; Width = 248.0f; Background = Support.UnicolorSprite("white", 255, 255, 255, 255); Background.Scale = new Vector2(Width/16.0f, 128.0f/16.0f); Background.RegisterPalette(0); this.AddChild(Background); // PossibleSolutionsText = new Label() { // Text = "all possible solutions:", // FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold" ) ), // Position = new Vector2(40.0f, 180.0f) // }; // PossibleSolutionsText.RegisterPalette(0); // this.AddChild( PossibleSolutionsText ); // MessageText = new Label() { // Text = "you clever thing.", // FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 32, "Bold" ) ), // }; // MessageText.RegisterPalette(0); // this.AddChild( MessageText ); ReplayButton = new BetterButton(94.0f + 30.0f, Background.CalcSizeInPixels().Y * Background.Scale.Y) { Text = "replay", TextFont = FontManager.Instance.GetInGame("Bariol", 25), Icon = Support.SpriteFromFile("/Application/assets/images/UI/replay.png"), IconAndTextOffset = new Vector2(32.0f, 10.0f), TextOffset = new Vector2(-45.0f, -45.0f), Position = new Vector2(Width - 124.0f, 0.0f), // Color = new Vector4(0.1608f, 0.8863f, 0.8863f, 1.0f) }; ReplayButton.background.RegisterPalette(0); ReplayButton.Icon.Color = LevelManager.Instance.BackgroundColor; ReplayButton.TextColor = LevelManager.Instance.BackgroundColor; this.AddChild(ReplayButton); QuitButton = new BetterButton(94.0f + 30.0f, Background.CalcSizeInPixels().Y * Background.Scale.Y) { Text = "menu", TextFont = FontManager.Instance.GetInGame("Bariol", 25), Icon = Support.SpriteFromFile("/Application/assets/images/UI/arrow.png"), IconAndTextOffset = new Vector2(32.0f, 80.0f), TextOffset = new Vector2(-38.0f, -45.0f), Position = new Vector2(Width - ReplayButton.Width - 124.0f, 0.0f), // Color = new Vector4(0.1608f, 0.8863f, 0.8863f, 1.0f) }; QuitButton.background.RegisterPalette(0); QuitButton.Icon.Color = LevelManager.Instance.BackgroundColor; QuitButton.Icon.Rotation = new Vector2(0.0f, -1.0f); QuitButton.TextColor = LevelManager.Instance.BackgroundColor; this.AddChild(QuitButton); Height = QuitButton.Height; // var charHeight = MessageText.FontMap.CharPixelHeight; // Height = (charHeight * 5.0f) + QuitButton.Height; // MessageText.Position = new Vector2(40.0f, QuitButton.Height + 20 ); // CenterText(); #if DEBUG Console.WriteLine(GetType().ToString() + " created" ); #endif }
// CONSTRUCTOR -------------------------------------------------------------------------------------------------------------------------------------- public NextLevelPanel() { DismissDelay = 0.0f; Width = 458.0f; Background = Support.UnicolorSprite("white", 255, 255, 255, 255); Background.Scale = new Vector2(448.0f/16.0f, 128.0f/16.0f); Background.RegisterPalette(0); this.AddChild(Background); // MessageText = new Label() { // Text = "you clever thing.", // FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 32, "Bold" ) ), // }; // MessageText.RegisterPalette(0); // this.AddChild( MessageText ); NextLevelButton = new BetterButton(78.0f + 30.0f, Background.CalcSizeInPixels().Y * Background.Scale.Y) { Text = "next", TextFont = FontManager.Instance.GetInGame("Bariol", 25), // IconOnLeft = false, // Icon = Support.SpriteFromFile("/Application/assets/images/UI/arrow.png"), Icon = Support.SpriteFromAtlas("crystallonUI", "arrow.png"), IconAndTextOffset = new Vector2(22.0f, 10.0f), TextOffset = new Vector2(-40.0f, -45.0f), Position = new Vector2(Width - 108.0f, 0.0f), // Color = new Vector4(0.8980f, 0.0745f, 0.0745f, 1.0f) }; NextLevelButton.background.RegisterPalette(0); NextLevelButton.Icon.Color = LevelManager.Instance.BackgroundColor; NextLevelButton.TextColor = LevelManager.Instance.BackgroundColor; // NextLevelButton.Icon.RegisterPalette(1); // NextLevelButton.ButtonLabel.RegisterPalette(1); this.AddChild(NextLevelButton); LevelSelectButton = new BetterButton(80.0f + 30.0f, Background.CalcSizeInPixels().Y * Background.Scale.Y) { Text = "select", Icon = Support.SpriteFromFile("/Application/assets/images/UI/levels.png"), IconAndTextOffset = new Vector2(55.0f, 40.0f), TextOffset = new Vector2(-65.0f, -45.0f), // Icon = Support.SpriteFromAtlas("crystallonUI", "levels.png"), // IconAndTextOffset = new Vector2(30.0f, 10.0f), // TextOffset = new Vector2(-35.0f, -45.0f), TextFont = FontManager.Instance.GetInGame("Bariol", 25), Position = new Vector2(Width - NextLevelButton.Width - 110.0f, 0.0f), }; LevelSelectButton.background.RegisterPalette(0); LevelSelectButton.Icon.Color = LevelManager.Instance.BackgroundColor; LevelSelectButton.TextColor = LevelManager.Instance.BackgroundColor; this.AddChild(LevelSelectButton); ReplayButton = new BetterButton(94.0f + 30.0f, Background.CalcSizeInPixels().Y * Background.Scale.Y) { Text = "replay", TextFont = FontManager.Instance.GetInGame("Bariol", 25), // Icon = Support.SpriteFromFile("/Application/assets/images/UI/replay.png"), Icon = Support.SpriteFromAtlas("crystallonUI", "replay.png"), IconAndTextOffset = new Vector2(32.0f, 10.0f), TextOffset = new Vector2(-45.0f, -45.0f), Position = new Vector2(Width - NextLevelButton.Width - LevelSelectButton.Width - 124.0f, 0.0f), // Color = new Vector4(0.1608f, 0.8863f, 0.8863f, 1.0f) }; ReplayButton.background.RegisterPalette(0); ReplayButton.Icon.Color = LevelManager.Instance.BackgroundColor; ReplayButton.TextColor = LevelManager.Instance.BackgroundColor; // this.AddChild(ReplayButton); QuitButton = new BetterButton(94.0f + 30.0f, Background.CalcSizeInPixels().Y * Background.Scale.Y) { Text = "menu", TextFont = FontManager.Instance.GetInGame("Bariol", 25), // Icon = Support.SpriteFromFile("/Application/assets/images/UI/arrow.png"), Icon = Support.SpriteFromAtlas("crystallonUI", "arrow.png"), IconAndTextOffset = new Vector2(32.0f, 80.0f), TextOffset = new Vector2(-38.0f, -45.0f), Position = new Vector2(Width - NextLevelButton.Width - LevelSelectButton.Width - 124.0f, 0.0f), // Color = new Vector4(0.1608f, 0.8863f, 0.8863f, 1.0f) }; QuitButton.background.RegisterPalette(0); QuitButton.Icon.Color = LevelManager.Instance.BackgroundColor; QuitButton.Icon.Rotation = new Vector2(0.0f, -1.0f); QuitButton.TextColor = LevelManager.Instance.BackgroundColor; // this.AddChild(QuitButton); if(GameScene.currentLevel != 0) { this.AddChild(ReplayButton); } else { this.AddChild(QuitButton); } // DiagonalLine = Support.SpriteFromFile("/Application/assets/images/UI/diagonalLine.png"); DiagonalLine = Support.SpriteFromAtlas("crystallonUI", "diagonalLine.png"); DiagonalLine.Position = new Vector2( QuitButton.Position.X - DiagonalLine.CalcSizeInPixels().X - 5.0f , 15.0f); DiagonalLine.Color = LevelManager.Instance.BackgroundColor; this.AddChild(DiagonalLine); PossibleSolutionsText = new Label() { Text = "solutions\n found", FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 14, "Bold" ) ), Position = new Vector2(15.0f, 80.0f) }; // PossibleSolutionsText.RegisterPalette(0); PossibleSolutionsText.Color = LevelManager.Instance.BackgroundColor; this.AddChild( PossibleSolutionsText ); OutOfText = new Label() { Text = "out of", FontMap = PossibleSolutionsText.FontMap, Position = new Vector2(60.0f, 40.0f) }; OutOfText.Color = LevelManager.Instance.BackgroundColor; this.AddChild( OutOfText ); FoundSolutionsText = new Label() { Text = "00", FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold" ) ), Position = new Vector2(24.0f, 90.0f) }; FoundSolutionsText.Color = LevelManager.Instance.BackgroundColor; this.AddChild(FoundSolutionsText); TotalSolutionsText = new Label{ Text = "00", FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold" ) ), Position = new Vector2(62.0f, 15.0f) }; TotalSolutionsText.Color = LevelManager.Instance.BackgroundColor; this.AddChild(TotalSolutionsText); // var charHeight = MessageText.FontMap.CharPixelHeight; // Height = (charHeight * 5.0f) + QuitButton.Height; Height = QuitButton.Height; // MessageText.Position = new Vector2(40.0f, QuitButton.Height + 20 ); // CenterText(); #if DEBUG Console.WriteLine(GetType().ToString() + " created" ); #endif }
public static void Main(string[] args) { Sce.PlayStation.Core.Graphics.GraphicsContext context = new Sce.PlayStation.Core.Graphics.GraphicsContext(); uint sprites_capacity = 500; uint draw_helpers_capacity=400; System.Random rand = new System.Random(); Director.Initialize(sprites_capacity, draw_helpers_capacity, context); Director.Instance.GL.Context.SetClearColor(Colors.Grey20); var scene = new Scene(); scene.Camera.SetViewFromViewport(); Director.Instance.RunWithScene(scene,true); _physics = new GamePhysics(); holder = new Node(); var _screenWidth = Director.Instance.GL.Context.GetViewport().Width; var _screenHeight = Director.Instance.GL.Context.GetViewport().Height; currentLevelData = LevelData.LEVEL_DATA[0]; cards = new Card[currentLevelData.Length]; for (int i = 0; i < cards.Length; i++) { Vector2 start_pos = new Vector2(50f + 0.75f * _screenWidth * (float)rand.NextDouble(), 50f + 0.75f * _screenHeight * (float)rand.NextDouble ()); cards[i] = new Card(_physics.addCardPhysics(start_pos), currentLevelData[i]); holder.AddChild (cards[i]); } scene.AddChild(holder); //cubeFaces = new SpriteSingleton(); cubeFaces = SpriteSingleton.getInstance(); sprite = cubeFaces.Get("topSide"); sprite.Name = "topSide"; sprite2 = cubeFaces.Get ("leftSide"); sprite2.Name = "leftSide"; sprite3 = cubeFaces.Get("rightSide"); sprite3.Name = "rightSide"; Vector2 vectHolder = sprite2.CalcSizeInPixels(); sprite3.Position = new Vector2(vectHolder.X-84, sprite3.Position.Y); sprite.Position = new Vector2(vectHolder.X/4, (sprite.Position.Y + vectHolder.X/2)-12); //sprite3.Position = new Vector2(sprite2.Position.Length, // sprite2.Position.Y); //sprite.Position = scene.Camera.CalcBounds().Center; //sprite.CenterSprite(); //sprite.Scale = new Vector2(1,1); cube3 = new Node(); cube3.AddChild(sprite); cube3.AddChild(sprite2); cube3.AddChild(sprite3); scene.AddChild(cube3); //pink //sprite.RunAction(new TintTo (new Vector4(0.96f,0.88f,0.88f,1.0f),0.1f)); //red //sprite.RunAction(new TintTo (new Vector4(0.90f,0.075f,0.075f,1.0f),0.1f)); var spriteName="topSide"; sprite.TileIndex2D = cubeFaces.Get (spriteName).TileIndex2D; Console.WriteLine(sprite.TileIndex2D); //teal //sprite.RunAction(new TintTo (new Vector4(0.16f,0.88f,0.88f,1.0f),0.1f)); var cube = new Cube(); cube.card1("red"); cube.card2 ("blue"); cube.card3("blue"); while(!Input2.GamePad0.Cross.Press) { var vect = new Vector2(cube3.Position.X +10, cube3.Position.Y +3); cube3.Position = vect; Sce.PlayStation.Core.Environment.SystemEvents.CheckEvents(); Director.Instance.Update(); Director.Instance.Render(); Director.Instance.GL.Context.SwapBuffers(); Director.Instance.PostSwap(); cube.testCube(); } }
// METHODS ------------------------------------------------------------------------------ protected void Initialize() { _initialized = true; Background = Support.SpriteFromFile("/Application/assets/images/LevelTitleBG.png"); Background.Position = new Vector2(0.0f, 0.0f); this.AddChild(Background); this.Height = Background.CalcSizeInPixels().Y; this.Width = Background.CalcSizeInPixels().X; QualityNames = new List<Label>(); map = Crystallography.UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 18, "Regular")); LevelNumberText = new Label(){ Text = "00", FontMap = Crystallography.UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 102, "Bold")), Position = new Vector2( 44.0f, 250.0f), // Color = new Vector4( 0.16078431f, 0.88627451f, 0.88627451f, 1.0f) }; LevelNumberText.RegisterPalette(0); Background.AddChild(LevelNumberText); TapToDismissText = new Label() { Text = "tap to dismiss", FontMap = map, Position = new Vector2( 39.0f, 20.0f) }; TapToDismissText.RegisterPalette(0); Background.AddChild(TapToDismissText); Icons = new SpriteTile[4]; for( int i=0; i < Icons.Length; i++) { Icons[i] = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2); float y = 176.0f - 88.0f * (float)System.Math.Floor(i/2.0f); Icons[i].Position = new Vector2( 44.0f + 68.0f*(i%2), y); Background.AddChild(Icons[i]); Icons[i].Visible = false; } }
public virtual void setSymbol( int? pSymbol ) { _symbolIndex = pSymbol; if (_symbolIndex == null) { if(_symbol != null) { getNode().RemoveChild(_symbol, true); } _symbol = null; return; } string orient; switch(getOrientation()) { case(0): default: orient = "T"; break; case(1): orient = "L"; break; case(2): orient = "R"; break; } if (_symbol == null) { // _symbol = new SpriteTile(QSymbol.Instance.symbolTiles.TextureInfo); _symbol = new SpriteTile(Support.TextureInfoFromAtlas("symbol", LevelManager.Instance.SymbolPath + "_v" + pSymbol.ToString() + "_" + orient + ".png")); _symbol.Scale = _symbol.CalcSizeInPixels(); _symbol.Position = _symbol.Scale/-2.0f; _symbol.RegisterPalette(_colorIndex); getNode().AddChild(_symbol); } // _symbol.TileIndex2D.X = _orientationIndex; // _symbol.TileIndex2D.Y = _symbolIndex ?? 0; }
public virtual void setGlow(int pGlow) { if (pGlow == -1) { HideGlow(); this.getNode().RemoveChild(GlowSprite, true); GlowSprite = null; return; } _glowIndex = pGlow; GlowSprite = new SpriteTile(QGlow.Instance.GlowTiles.TextureInfo, _orientationIndex); GlowSprite.Scale = GlowSprite.CalcSizeInPixels(); GlowSprite.Position = GlowSprite.Scale/-2.0f; HideGlow(); this.getNode().AddChild(GlowSprite); }
public void setAnim( SpriteTile anim, int pStart, int pEnd ) { // REMOVE ANY PREVIOUSLY APPLIED ANIMATION if (_anim != null) { this.getNode().RemoveChild(_anim, true); _anim = null; } // IF SET TO "NO ANIMATION", WE'RE DONE. if (pStart == pEnd) { return; } _anim = new SpriteTile( anim.TextureInfo, anim.TileIndex2D ); _anim.Scale = _anim.CalcSizeInPixels(); _anim.RegisterPalette(_colorIndex); _anim.Position = _anim.Scale/-2.0f; // _anim.Pivot = this.getNode().Pivot; _anim.RunAction( new Support.AnimationAction(_anim, pStart, pEnd, 0.1f*(1+pEnd-pStart), true) ); if (getOrientation() == 2) { _anim.FlipU = true; } this.getNode().AddChild(_anim); }