public static Sce.PlayStation.HighLevel.GameEngine2D.SpriteTile SpriteFromFile(string filename) { if (TextureCache.ContainsKey(filename) == false) { TextureCache[filename] = new Texture2D(filename, false); TextureInfoCache[filename] = new TextureInfo(TextureCache[filename], new Vector2i(1, 1)); } var tex = TextureCache[filename]; var info = TextureInfoCache[filename]; // Vector2i tilesize=new Vector2i(256,256); // if ( info.TextureSize ) // { // } var result = new Sce.PlayStation.HighLevel.GameEngine2D.SpriteTile() { TextureInfo = info, }; result.Quad.S = new Vector2(info.Texture.Width, info.Texture.Height); // result.Quad.S = info.TextureSizef; // DEBUG: testing for current assets result.Scale = new Vector2(1.0f); tex.SetFilter(DefaultTextureFilterMode); return result; }
public TitleScene() { this.Camera.SetViewFromViewport(); _texture = new Texture2D("Application/images/title.png",false); _ti = new TextureInfo(_texture); SpriteUV titleScreen = new SpriteUV(_ti); titleScreen.Scale = _ti.TextureSizef; titleScreen.Pivot = new Vector2(0.5f,0.5f); titleScreen.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width/2, Director.Instance.GL.Context.GetViewport().Height/2); this.AddChild(titleScreen); Vector4 origColor = titleScreen.Color; titleScreen.Color = new Vector4(0,0,0,0); var tintAction = new TintTo(origColor,10.0f); ActionManager.Instance.AddAction(tintAction,titleScreen); tintAction.Run(); _titleSong = new Bgm("/Application/audio/titlesong.mp3"); if(_songPlayer != null) _songPlayer.Dispose(); _songPlayer = _titleSong.CreatePlayer(); Scheduler.Instance.ScheduleUpdateForTarget(this,0,false); // Clear any queued clicks so we dont immediately exit if coming in from the menu Touch.GetData(0).Clear(); }
public TitleScene() { this.Camera.SetViewFromViewport(); _texture = new Texture2D("/Application/assets/images/header.png",false); _ti = new TextureInfo(_texture); SpriteUV titleScreen = new SpriteUV(_ti); titleScreen.Scale = _ti.TextureSizef; titleScreen.Pivot = new Vector2(0.5f,0.5f); titleScreen.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width/2, Director.Instance.GL.Context.GetViewport().Height/2); this.AddChild(titleScreen); Vector4 origColor = titleScreen.Color; titleScreen.Color = new Vector4(0,0,0,0); var tintAction = new TintTo(origColor,10.0f); ActionManager.Instance.AddAction(tintAction,titleScreen); tintAction.Run(); // MUSIC Support.MusicSystem.Instance.Play("play.mp3"); Scheduler.Instance.ScheduleUpdateForTarget(this,0,false); // Clear any queued clicks so we dont immediately exit if coming in from the menu Touch.GetData(0).Clear(); }
public TitleScene() { if(AppMain.am == null) { AppMain.am = new AudioManager(); } else { AppMain.am.changeSong(false); } this.Camera.SetViewFromViewport(); _texture = new Texture2D("/Application/images/title.png", false); _textureInfo = new TextureInfo(_texture); SpriteUV titleScreen = new SpriteUV(_textureInfo); titleScreen.Scale = _textureInfo.TextureSizef; titleScreen.Pivot = new Vector2(0.5f, 0.5f); ImageRect viewPort = Director.Instance.GL.Context.GetViewport(); titleScreen.Position = new Vector2(viewPort.Width/2, viewPort.Height/2); this.AddChild(titleScreen); Vector4 origColour = titleScreen.Color; titleScreen.Color = new Vector4(0,0,0,0); var tintAction = new TintTo(origColour, 10.0f); ActionManager.Instance.AddAction(tintAction, titleScreen); tintAction.Run(); Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false); // Clear any queued clicks so we don't immediately exit if coming in from the menu Touch.GetData (0).Clear(); }
// CONSTRUCTOR --------------------------------------------------------------------------------------- public AnimationGlitchSpriteSingleton() { if(!isOkToCreate) Console.WriteLine (this + "is a singleton. Use get instance"); if(isOkToCreate){ FileStream fileStream = File.OpenRead("/Application/assets/animation/leftGlitch/leftOneLine.xml"); StreamReader fileStreamReader = new StreamReader(fileStream); string xml = fileStreamReader.ReadToEnd(); fileStreamReader.Close(); fileStream.Close(); XDocument doc = XDocument.Parse(xml); var lines = from sprite in doc.Root.Elements("sprite") select new { Name = sprite.Attribute("n").Value, X1 = (int)sprite.Attribute ("x"), Y1 = (int)sprite.Attribute ("y"), Height = (int)sprite.Attribute ("h"), Width = (int)sprite.Attribute("w"), }; _sprites = new Dictionary<string,Sce.PlayStation.HighLevel.GameEngine2D.Base.Vector2i>(); foreach(var curLine in lines) { _sprites.Add(curLine.Name,new Vector2i((curLine.X1/curLine.Width),(curLine.Y1/curLine.Height))); //note if you add more than one line of sprites you must do this // _sprites.Add(curLine.Name,new Vector2i((curLine.X1/curLine.Width),1-(curLine.Y1/curLine.Height))); //where 9 is the num of rows minus 1 to reverse the order :/ } _texture = new Texture2D("/Application/assets/animation/leftGlitch/leftOneLine.png", false); _textureInfo = new TextureInfo(_texture,new Vector2i(5,1)); } if(!isOkToCreate) { Console.WriteLine("this is a singleton. access via get Instance"); } }
public WaterTile(TextureInfo texInfo) : base(texInfo) { _timer = new Timer(); _delay = 3000; _timer.Reset(); }
public InstructionsScene() { this.Camera.SetViewFromViewport(); _texture = new Texture2D("/Application/assets/images/allSame.png",false); // started working out game logic in a seperate project Card Match Login _ti = new TextureInfo(_texture); SpriteUV titleScreen = new SpriteUV(_ti); titleScreen.Scale = _ti.TextureSizef; titleScreen.Pivot = new Vector2(0.5f,0.5f); titleScreen.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width/2, Director.Instance.GL.Context.GetViewport().Height/2); this.AddChild(titleScreen); Vector4 origColor = titleScreen.Color; titleScreen.Color = new Vector4(0,0,0,0); var tintAction = new TintTo(origColor,10.0f); ActionManager.Instance.AddAction(tintAction,titleScreen); tintAction.Run(); Scheduler.Instance.ScheduleUpdateForTarget(this,0,false); // Clear any queued clicks so we dont immediately exit if coming in from the menu Touch.GetData(0).Clear(); }
public FishEnemy(Vector2 pos, PlayerCreature player) { enemyHabitat = Enemy.EnemyHabitat.ENEMY_HABITAT_SEA; enemyType = Enemy.EnemyType.ENEMY_TYPE_FISH; sprite = new SpriteTile(); this.player = player; if (texInfo == null) { //texInfo = new TextureInfo ("/Application/assets/stingray_float.png"); texInfo = new TextureInfo(AssetManager.GetTexture("stingray_float"), new Vector2i(4,1),TRS.Quad0_1); } if (spriteList == null) { spriteList = new SpriteList(texInfo); } spriteList.Position = new Vector2(0.0f,0.0f); spriteList.AddChild(sprite); Animations = new Dictionary<string, Animation>(); //texInfo = new TextureInfo(AssetManager.GetTexture("stingray_float"), new Vector2i(4,1),TRS.Quad0_1); Animations.Add("idle" , new Animation(0, 3, 0.3f, false)); CurrentAnimation = Animations["idle"]; CurrentAnimation.Play(); sprite.GetContentWorldBounds(ref boundingBox); sprite.Quad.S = new Vector2(321, 270);// map 1:1 on screen -- necessary? !!!\ sprite.CenterSprite(); sprite.Position = pos; sprite.Schedule((dt) => UpdateEnemyState(dt)); }
public static void InitRayer() { CharacterStackTexture = new Texture2D[5]; CharacterStackTextureInfo = new TextureInfo[5]; var image0 = new Image("/Application/resourses/myCharacterStack.png"); var image04 = image0.Crop(new ImageRect(0,0,128,32)); var image03 = image0.Crop(new ImageRect(0,32,128,32)); var image02 = image0.Crop(new ImageRect(0,64,128,32)); var image01 = image0.Crop(new ImageRect(0,96,128,32)); var image00 = image0.Crop(new ImageRect(0,128,128,32)); CharacterStackTexture[0] = Convert.CreateTextureFromImage(image00); CharacterStackTextureInfo[0] = new TextureInfo(CharacterStackTexture[0]); CharacterStackTexture[1] = Convert.CreateTextureFromImage(image01); CharacterStackTextureInfo[1] = new TextureInfo(CharacterStackTexture[1]); CharacterStackTexture[2] = Convert.CreateTextureFromImage(image02); CharacterStackTextureInfo[2] = new TextureInfo(CharacterStackTexture[2]); CharacterStackTexture[3] = Convert.CreateTextureFromImage(image03); CharacterStackTextureInfo[3] = new TextureInfo(CharacterStackTexture[3]); CharacterStackTexture[4] = Convert.CreateTextureFromImage(image04); CharacterStackTextureInfo[4] = new TextureInfo(CharacterStackTexture[4]); image0.Dispose(); image00.Dispose(); image01.Dispose(); image02.Dispose(); image03.Dispose(); image04.Dispose(); }
public void Render( Texture2D texture, Scene scene) { TextureInfo ti1 = new TextureInfo(); //if(flip) ti1.Texture = texture; // else // ti1.Texture = texture1; SpriteUV sprite1 = new SpriteUV(); sprite1.TextureInfo = ti1; if(type==0) sprite1.Quad.S = ti1.TextureSizef.Multiply(.3f); if(type==1) sprite1.Quad.S = ti1.TextureSizef.Multiply(.05f); sprite1.CenterSprite(); sprite1.Position = position;// scene.Camera.CalcBounds().Center; sprite1.Rotate(-rotation);//*Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Pi/180); scene.AddChild(sprite1); }
public TextureAtlas(string filename) { sprites = new Dictionary<string, Bounds2>(); sizes = new Dictionary<string, Vector2i>(); XDocument doc = XDocument.Load(filename + ".xml"); var lines = from sprite in doc.Root.Elements("sprite") select new { Name = sprite.Attribute("n").Value, X1 = (float)sprite.Attribute("x"), Y1 = (float)sprite.Attribute("y"), Height = (float)sprite.Attribute("h"), Width = (float)sprite.Attribute("w") }; texAtlas = new Texture2D(filename + ".png", false); texAtlasInfo = new TextureInfo(texAtlas); foreach (var curLine in lines) { sprites.Add(curLine.Name, new Bounds2(new Vector2(curLine.X1 / texAtlas.Width, 1 - (curLine.Y1 / texAtlas.Height)), new Vector2((curLine.X1 + curLine.Width) / texAtlas.Width, 1 -((curLine.Y1 + curLine.Height) / texAtlas.Height)))); sizes.Add(curLine.Name, new Vector2i((int)curLine.Width, (int)curLine.Height)); } }
public static void InitEnemyBullet() { BulletList = new ArrayList(); BulletTexture = new Texture2D[4]; BulletTextureInfo = new TextureInfo[4]; var image2 = new Image("/Application/resourses/Bullet01_16x16.png"); var image20 = image2.Crop(new ImageRect(0,0,16,16)); var image21 = image2.Crop(new ImageRect(0,16,16,16)); var image22 = image2.Crop(new ImageRect(0,32,16,16)); var image23 = image2.Crop(new ImageRect(0,48,16,16)); BulletTexture[0] = Convert.CreateTextureFromImage(image20); BulletTextureInfo[0] = new TextureInfo(BulletTexture[0]); BulletTexture[1] = Convert.CreateTextureFromImage(image21); BulletTextureInfo[1] = new TextureInfo(BulletTexture[1]); BulletTexture[2] = Convert.CreateTextureFromImage(image22); BulletTextureInfo[2] = new TextureInfo(BulletTexture[2]); BulletTexture[3] = Convert.CreateTextureFromImage(image23); BulletTextureInfo[3] = new TextureInfo(BulletTexture[3]); image2.Dispose(); image20.Dispose(); image21.Dispose(); image22.Dispose(); image23.Dispose(); }
// CONSTRUCTOR ---------------------------------------------------------------------------- public ButtonEntity( string pLabel, Scene pScene, GamePhysics pGamePhysics, TextureInfo pTextureInfo, Vector2i pTileIndex2D ) : base(pScene, pGamePhysics, pTextureInfo, pTileIndex2D, null) { halfWidth = Width / 2.0f; halfHeight = Height / 2.0f; labelOffset = new Vector2(0.1f, 0.25f); this.setPivot(0.5f,0.5f); font = Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25); map = Crystallography.UI.FontManager.Instance.GetMap( font ); if ( pLabel != null ) { label = new Label( pLabel, map ); label.Pivot = new Vector2(0.15f, 0.25f ); label.Scale = new Vector2(1.0f/this.Width,1.0f/this.Height); } this.getNode().AddChild(label); labelOffset = Vector2.Zero; status = NORMAL; _onToggle = false; _pressed = false; _initialized = false; #if DEBUG Console.WriteLine(GetType().ToString() + " created" ); #endif }
public void AddTextureAsset(String path, Object user, Int32 u, Int32 v) { if (String.IsNullOrWhiteSpace(path)) throw new ArgumentException(); if (user == null) throw new ArgumentNullException(); Vector2i tiles = new Vector2i(u, v); if (TextureAssetsByUsers.ContainsKey(path)) { if (TextureAssetsByUsers[path].TextureInfo.NumTiles != tiles) throw new ArgumentException("Duplicate texture asset with different tiles: " + path); TextureAssetsByUsers[path].AddUser(user); } else { Texture2D t = new Texture2D(path, false); TextureInfo ti = new TextureInfo(t, tiles); TextureAssetsByUsers[path] = new TextureUsers(ti, user); } }
/// <summary>SpriteRenderer constructor.</summary> public SpriteRenderer(GraphicsContextAlpha gl, uint max_sprites) { GL = gl; m_imm_quads = new ImmediateModeQuads< Vector4 >( GL, (uint)max_sprites, VertexFormat.Float4 ); { // init the font texture used by DrawTextDebug Texture2D font_texture = EmbeddedDebugFontData.CreateTexture(); m_embedded_font_texture_info = new TextureInfo(); m_embedded_font_texture_info.Initialize( font_texture, new Vector2i( EmbeddedDebugFontData.NumChars, 1 ), new TRS( new Bounds2( new Vector2(0.0f, 0.0f), new Vector2( (EmbeddedDebugFontData.CharSizei.X * EmbeddedDebugFontData.NumChars ) / (float)font_texture.Width, (EmbeddedDebugFontData.CharSizei.Y / (float)font_texture.Height) ) ) ) ); } }
public Bullet(Vector2 pos) { sprite = new SpriteUV(); if (texInfo == null) { texInfo = new TextureInfo ("/Application/assets/bubble.png"); //texInfo = new TextureInfo(AssetManager.GetTexture("bubble"), new Vector2i(4,1),TRS.Quad0_1); } if (spriteList == null) { spriteList = new SpriteList(texInfo); spriteList.Position = new Vector2(0.0f,0.0f); } spriteList.AddChild(sprite); sprite.Quad.S = texInfo.TextureSizef; // map 1:1 on screen -- necessary? !!!\ sprite.RunAction(new ScaleTo(new Vector2(0.15f,0.15f),0.0f)); sprite.GetContentWorldBounds(ref boundingBox); boundingBox = new Bounds2(pos, new Vector2(38,38)); //sprite.CenterSprite(); sprite.Position = pos; sprite.Schedule((dt) => Update()); }
public static void PrecacheTiledSprite(string filename, int x, int y) { if (TextureCache.ContainsKey(filename) == false) { TextureCache[filename] = new Texture2D(filename, false); TextureInfoCache[filename] = new TextureInfo(TextureCache[filename], new Vector2i(x, y)); } }
public BulletEntity(string path,float scale) { //スプライト生成 var texture_info = new TextureInfo(new Texture2D(path,false),new Vector2i(1,1)); Sprite = createSprite (texture_info); this.AddChild(Sprite); }
public void OpenTextureInFile(string name) { textureforOpening = new Texture2D(AssetsPrefix + name,false); tInfor = new TextureInfo(textureforOpening); sprite = new SpriteUV(tInfor); spriteList = new Sce.PlayStation.HighLevel.GameEngine2D.SpriteList(tInfor); spriteList.AddChild(sprite); }
private void generateFireleafSprite() { var texture = new Texture2D ("/Application/Assets/images/fireleaf_one.png", false); var textureInfo = new TextureInfo (texture); this.RegisterDisposeOnExit (textureInfo); var sprite = new SpriteUV (textureInfo); sprite.Quad.S = textureInfo.TextureSizef; AddChild (sprite); }
public static void Main (string[] args) { Director.Initialize(); Director.Instance.GL.Context.SetClearColor( Colors.Grey20 ); //Director.Instance.DebugFlags |= DebugFlags.Navigate; Vector2 position = new Vector2(300,300); Vector2i sprIndex1 = new Vector2i(0,0); int step = 0; var scene = new Scene(); var texture_info = new TextureInfo( new Texture2D("/Application/Dude1.png", false ), new Vector2i(2,1)); var sprite = new SpriteTile(texture_info, sprIndex1); scene.Camera.SetViewFromViewport(); sprite.Quad.S = texture_info.TextureSizef; scene.AddChild( sprite ); var sprite2 = new SpriteUV() { TextureInfo = texture_info}; sprite2.Quad.S = texture_info.TextureSizef; scene.AddChild( sprite2 ); //sprite2.Position = scene.Camera.CalcBounds().Center; sprite2.Position = position; Director.Instance.RunWithScene( scene ); Initialize (); sprite.TileIndex2D = new Vector2i(1,0); while (true) { GamePadData presses = GamePad.GetData(0); //step++; //if (step == 20) if ((presses.Buttons & GamePadButtons.Down) != 0){ sprite.TileIndex2D.X = 0; position.X++; } //sprIndex1.X = 0; //if (step > 40){ // step = 0; else sprite.TileIndex2D.X = 1; //sprIndex1.X = 1; //} //sprite.TileIndex2D = sprIndex1; SystemEvents.CheckEvents (); Update (); Render (); } }
private void setSprite() { Texture2D texture = new Texture2D(spritePath,false); TextureInfo textureInfo = new TextureInfo(texture); float pivotCenter = 0.5f; this.sprite = new SpriteUV(textureInfo); this.sprite.Scale = textureInfo.TextureSizef/2; this.sprite.Pivot = new Vector2(pivotCenter,pivotCenter); this.sprite.Position = new Vector2(this.x, this.y); this.AddChild(this.sprite); }
public BackGround(Vector2 pos,string path,float scale) { //スプライト生成 texture_info = new TextureInfo(new Texture2D(path,false),new Vector2i(1,1)); Sprite = createSprite (texture_info,scale); //座標設定 this.Position = pos; //スプライトをNodeに追加する this.AddChild(Sprite); }
public BulletEntity(Vector2 pos,string path) { //座標設定 this.Position = pos; //スプライト生成 var texture_info = new TextureInfo(new Texture2D(path,false),new Vector2i(1,1)); Sprite = createSprite (texture_info); //スプライトをNodeに追加する this.AddChild(Sprite); }
public void setTextureArray(string[] array) { int i; for(i = 0; i < array.Length; i++) { //GameLog.DebugLog.Log("" + i); string path = array[i]; textureInfoArray[i] = new TextureInfo( new Texture2D("/Application/resources/" + path, false) ); } this.TextureInfo = textureInfoArray[texture_num]; }
public PlayerCreature() { Animations = new Dictionary<string, Animation>(); texInfo = new TextureInfo(AssetManager.GetTexture("spritesheet"), new Vector2i(2,2), TRS.Quad0_1); Animations.Add("idle" , new Animation(0, 2, 0.4f, false)); CurrentAnimation = Animations["idle"]; CurrentAnimation.Play(); sprite = new SpriteTile(texInfo); sprite.TileIndex1D = CurrentAnimation.CurrentFrame; sprite.Quad.S = texInfo.TextureSizef; isJumping = false; }
public StaticBackground() { var texture = new Texture2D ("/Application/Assets/background/background.jpg", false); var textureInfo = new TextureInfo (texture); this.RegisterDisposeOnExit (textureInfo); var sprite = new SpriteUV (textureInfo); sprite.Quad.S = textureInfo.TextureSizef; AddChild (sprite); Camera = new Camera2D (Director.Instance.GL, Director.Instance.DrawHelpers); Camera.SetViewFromViewport (); }
/// <summary> /// スコアを更新する /// </summary> /// <param name='inc'> /// 指定された分だけ増加させる /// </param> public static void UpdateScore(int inc){ Scenes.sceneOnGame.RemoveChild(scoreSprite,true); Global.score += inc; var texture = Convert.CreateTextureFromText("SCORE "+Global.score,new Font(FontAlias.System, 20, FontStyle.Bold),0xffffffff); var textureInfo = new TextureInfo(texture); scoreSprite = new SpriteUV(){TextureInfo = textureInfo}; scoreSprite.Quad.S = textureInfo.TextureSizef; scoreSprite.CenterSprite(); scoreSprite.Position = new Vector2(700,520); Scenes.sceneOnGame.AddChild(scoreSprite); }
public GameOverScene() { var texture = new Texture2D ("/Application/Assets/images/dead_scene.png", false); var textureInfo = new TextureInfo (texture); RegisterDisposeOnExit (textureInfo); var sprite = new SpriteUV (textureInfo); sprite.Quad.S = textureInfo.TextureSizef; AddChild (sprite); Camera = new Camera2D (Director.Instance.GL, Director.Instance.DrawHelpers); Camera.SetViewFromViewport (); ScheduleUpdate(2); }
private void generateFirewallSprite() { var texture = new Texture2D ("/Application/Assets/images/fireWall.png", false); var textureInfo = new TextureInfo (texture); this.RegisterDisposeOnExit (textureInfo); firewallSprite = new SpriteUV (textureInfo); float spriteWidth = 500.0f; float screenHeight = 544.0f; float spriteHeight = screenHeight; firewallSprite.Quad = new TRS (new Bounds2 (new Vector2 (-352.0f, 0.0f), new Vector2 (fireFrontLine + spriteWidth - 352.0f, spriteHeight))); firewallSprite.BlendMode = BlendMode.Additive; AddChild (firewallSprite); }