void CreateScene() { scene = new Scene(); scene.CreateComponent <Octree>(); // Create camera node CameraNode = scene.CreateChild("Camera"); // Set camera's position CameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f)); Camera camera = CameraNode.CreateComponent <Camera>(); camera.Orthographic = true; var graphics = Graphics; camera.OrthoSize = graphics.Height * PixelSize; camera.Zoom = 1.5f * Math.Min(graphics.Width / 1280.0f, graphics.Height / 800.0f); // Set zoom according to user's resolution to ensure full visibility (initial zoom (1.5) is set for full visibility at 1280x800 resolution) var cache = ResourceCache; AnimationSet2D animationSet = cache.GetAnimationSet2D("Urho2D/imp/imp.scml"); if (animationSet == null) { return; } spriteNode = scene.CreateChild("SpriterAnimation"); AnimatedSprite2D animatedSprite = spriteNode.CreateComponent <AnimatedSprite2D>(); animatedSprite.AnimationSet = animationSet; animatedSprite.SetAnimation(AnimationNames[animationIndex], LoopMode2D.Default); }
public void Start() { if (halfWidth == 0.0f) { random = new FloatRandom(); var graphics = AtomicNET.GetSubsystem<Graphics>(); halfWidth = graphics.Width * Constants.PIXEL_SIZE * 0.5f; halfHeight = graphics.Height * Constants.PIXEL_SIZE * 0.5f; animationSet = AtomicNET.Cache.GetResource<AnimationSet2D>("Sprites/butterfly.scml"); } speed = 1 + 2.0f * random.Random(); direction = random.Random() * (float)Math.PI * 2.0f; pos = Node.Position2D; sprite = (AnimatedSprite2D)Node.CreateComponent("AnimatedSprite2D"); sprite.Speed = .1f + random.Random() * 2.0f; sprite.AnimationSet = animationSet; sprite.SetAnimation("idle"); sprite.Color = new Color(.1f + random.Random() * .9f, .1f + random.Random() * .9f, .1f + random.Random() * .9f, 1); sprite.BlendMode = BlendMode.BLEND_ALPHA; }
void LoadAnimations() { //Load aniamtions foreach (NamedSprite animatedSprite in animations) { Animation2D anim = new Animation2D(animatedSprite.sprite, animatedSprite.priority, animatedSprite.name, false, animatedSprite.loop, animatedSprite.fadeOut); _resourceManager.GetAnimationManager().AddAnimation(anim); } //Load animation Sets foreach (NamedSpriteSet animatedSpriteSet in animationSets) { List <Animation2D> animList = new List <Animation2D>(); foreach (NamedSprite animatedSprite in animatedSpriteSet.spriteList) { Animation2D anim = new Animation2D(animatedSprite.sprite, animatedSprite.priority, animatedSprite.name, false, animatedSprite.loop, animatedSprite.fadeOut); animList.Add(anim); } AnimationSet2D animSet = new AnimationSet2D(animatedSpriteSet.name, animList); _resourceManager.GetAnimationManager().AddAnimationSet(animSet); } //Load Temporary Sprites in the same fasion foreach (NamedSprite tempSprite in temporarySprites) { Animation2D anim = new Animation2D(tempSprite.sprite, tempSprite.priority, tempSprite.name, true, tempSprite.loop, tempSprite.fadeOut); TempSpriteManager.GetInstance().AddAnimation(anim); } }
protected override void OnShow(Node node, Asset asset) { AnimationSet2D animationSet = ResourceCache.GetAnimationSet2D(asset.RelativePathToAsset); AnimatedSprite2D animatedSprite = node.CreateComponent <AnimatedSprite2D>(); animatedSprite.AnimationSet = animationSet; animatedSprite.SetAnimation(animationSet.GetAnimation(0), LoopMode2D.Default); }
protected virtual void GenerateAnimationList() { AnimationManager animManager = ResourceManager.GetInstance().GetAnimationManager(); AnimationSet2D animSet = animManager.GetAnimationSet(animationSet); foreach (Animation2D anim in animSet.GetAnimationList()) { animationList.Add(anim); } }
protected override void GenerateAnimationList() { animationSet = animationSet.Insert(animationSet.Length, "_" + skinIndex.ToString()); Debug.Log(animationSet); AnimationManager animManager = ResourceManager.GetInstance().GetAnimationManager(); AnimationSet2D animSet = animManager.GetAnimationSet(animationSet); foreach (Animation2D anim in animSet.GetAnimationList()) { animationList.Add(anim); } }
void CreateScene() { scene = new Scene(); scene.CreateComponent <Octree>(); spriteNodes = new List <NodeInfo>((int)NumSprites); // Create camera node CameraNode = scene.CreateChild("Camera"); // Set camera's position CameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f)); Camera camera = CameraNode.CreateComponent <Camera>(); camera.Orthographic = true; var graphics = GetSubsystem <Graphics>(); camera.OrthoSize = (float)graphics.Height * PixelSize; var cache = GetSubsystem <ResourceCache>(); // Get sprite Sprite2D sprite = cache.Get <Sprite2D>("Urho2D/Aster.png"); if (sprite == null) { return; } float halfWidth = graphics.Width * 0.5f * PixelSize; float halfHeight = graphics.Height * 0.5f * PixelSize; for (uint i = 0; i < NumSprites; ++i) { Node spriteNode = scene.CreateChild("StaticSprite2D"); spriteNode.Position = (new Vector3(NextRandom(-halfWidth, halfWidth), NextRandom(-halfHeight, halfHeight), 0.0f)); StaticSprite2D staticSprite = spriteNode.CreateComponent <StaticSprite2D>(); // Set random color staticSprite.Color = (new Color(NextRandom(1.0f), NextRandom(1.0f), NextRandom(1.0f), 1.0f)); // Set blend mode staticSprite.BlendMode = BlendMode.BLEND_ALPHA; // Set sprite staticSprite.Sprite = sprite; // Add to sprite node vector spriteNodes.Add(new NodeInfo(spriteNode, new Vector3(NextRandom(-2.0f, 2.0f), NextRandom(-2.0f, 2.0f), 0.0f), NextRandom(-90.0f, 90.0f))); } // Get animation set AnimationSet2D animationSet = cache.Get <AnimationSet2D>("Urho2D/GoldIcon.scml"); if (animationSet == null) { return; } var spriteNode2 = scene.CreateChild("AnimatedSprite2D"); spriteNode2.Position = (new Vector3(0.0f, 0.0f, -1.0f)); AnimatedSprite2D animatedSprite = spriteNode2.CreateComponent <AnimatedSprite2D>(); // Set animation animatedSprite.AnimationSet = animationSet; animatedSprite.SetAnimation("idle", LoopMode2D.LM_DEFAULT); }
void CreateHUD() { float hscal = 0.4f; // // create a 2nd viewport and scene for a hud with sprites. // hudScene = new Scene(); hudScene.CreateComponent <Octree>(); // Create camera node var hudCam = hudScene.CreateChild("HudCamera"); // Set camera's position hudCam.SetPosition(new Vector3(0.0f, 0.0f, -10.0f)); hudCamera = hudCam.CreateComponent <Camera>(); hudCamera.SetOrthographic(true); var graphics = GetSubsystem <Graphics>(); hudCamera.SetOrthoSize((float)graphics.GetHeight() * PixelSize); //PIXEL_SIZE var cache = GetSubsystem <ResourceCache>(); // add a crosshair in the center of the screen var sprite = cache.GetResource <Sprite2D>("Textures/NinjaSnowWar/Sight.png"); var targetSprite_ = hudScene.CreateChild("targetSprite"); targetSprite_.SetPosition2D(new Vector2(0, 0)); targetSprite_.SetScale2D(new Vector2(0.75f, 0.75f)); var staticSprite = targetSprite_.CreateComponent <StaticSprite2D>(); staticSprite.SetSprite(sprite); // Set sprite staticSprite.SetBlendMode(AtomicEngine.BlendMode.BLEND_ALPHA); // Set blend mode staticSprite.SetAlpha(0.3f); // borrow the spinning coin from the 2DSprite example to show what the possibilities are float halfWidth = graphics.Width * 0.5f * PixelSize; float halfHeight = graphics.Height * 0.5f * PixelSize; // Get animation set AnimationSet2D animationSet = cache.Get <AnimationSet2D>("Urho2D/GoldIcon.scml"); if (animationSet == null) { return; } var spriteNode2 = hudScene.CreateChild("AnimatedSprite2D"); AnimatedSprite2D animatedSprite = spriteNode2.CreateComponent <AnimatedSprite2D>(); animatedSprite.AnimationSet = animationSet; // Set animation animatedSprite.SetAnimation("idle", LoopMode2D.LM_DEFAULT); spriteNode2.SetPosition2D(new Vector2(halfWidth - 0.4f, halfHeight - 0.4f)); // (bullet) mass, speed size feature huds filler.Push(cache.GetResource <Sprite2D>("Textures/hudfill1.png")); filler.Push(cache.GetResource <Sprite2D>("Textures/hudfill2.png")); filler.Push(cache.GetResource <Sprite2D>("Textures/hudfill3.png")); filler.Push(cache.GetResource <Sprite2D>("Textures/hudfill4.png")); filler.Push(cache.GetResource <Sprite2D>("Textures/hudfill5.png")); filler.Push(cache.GetResource <Sprite2D>("Textures/hudfill6.png")); Sprite2D spritem = cache.GetResource <Sprite2D>("Textures/hudmass.png"); Node hudm = hudScene.CreateChild("hudMass"); hudm.SetScale2D(new Vector2(hscal, hscal)); hudm.SetPosition2D(new Vector2(0f - (halfWidth / 3.0f), halfHeight - 0.4f)); StaticSprite2D hudSpritem = hudm.CreateComponent <StaticSprite2D>(); hudSpritem.SetSprite(spritem); hudSpritem.SetAlpha(0.9f); hudSpritem.SetBlendMode(AtomicEngine.BlendMode.BLEND_ALPHA); hudSpritem.SetOrderInLayer(3); Node hudfm = hudm.CreateChild("hudMassFill"); hudfm.SetScale2D(new Vector2(1f, 1f)); hudfm.SetPosition2D(new Vector2(0f, 0f)); StaticSprite2D hudSpritefm = hudfm.CreateComponent <StaticSprite2D>(); hudSpritefm.SetSprite(filler[0]); hudSpritefm.SetAlpha(0.9f); hudSpritefm.SetBlendMode(AtomicEngine.BlendMode.BLEND_ALPHA); hudSpritefm.SetOrderInLayer(-3); Sprite2D sprites = cache.GetResource <Sprite2D>("Textures/hudspeed.png"); Node huds = hudScene.CreateChild("hudSpeed"); huds.SetScale2D(new Vector2(hscal, hscal)); huds.SetPosition2D(new Vector2(0f, halfHeight - 0.4f)); StaticSprite2D hudSprites = huds.CreateComponent <StaticSprite2D>(); hudSprites.SetSprite(sprites); hudSprites.SetAlpha(0.9f); hudSprites.SetBlendMode(AtomicEngine.BlendMode.BLEND_ALPHA); hudSprites.SetOrderInLayer(3); Node hudsm = huds.CreateChild("hudSpeedFill"); hudsm.SetScale2D(new Vector2(1f, 1f)); hudsm.SetPosition2D(new Vector2(0f, 0f)); StaticSprite2D hudSpritesm = hudsm.CreateComponent <StaticSprite2D>(); hudSpritesm.SetSprite(filler[0]); hudSpritesm.SetAlpha(0.9f); hudSpritesm.SetBlendMode(AtomicEngine.BlendMode.BLEND_ALPHA); hudSpritesm.SetOrderInLayer(-3); Sprite2D spritez = cache.GetResource <Sprite2D>("Textures/hudsize.png"); Node hudz = hudScene.CreateChild("hudSize"); hudz.SetScale2D(new Vector2(hscal, hscal)); hudz.SetPosition2D(new Vector2(0f + (halfWidth / 3.0f), halfHeight - 0.4f)); StaticSprite2D hudSpritez = hudz.CreateComponent <StaticSprite2D>(); hudSpritez.SetSprite(spritez); hudSpritez.SetAlpha(0.9f); hudSpritez.SetBlendMode(AtomicEngine.BlendMode.BLEND_ALPHA); hudSpritez.SetOrderInLayer(3); Node hudzm = hudz.CreateChild("hudSizeFill"); hudzm.SetScale2D(new Vector2(1f, 1f)); hudzm.SetPosition2D(new Vector2(0f, 0f)); StaticSprite2D hudSpritezm = hudzm.CreateComponent <StaticSprite2D>(); hudSpritezm.SetSprite(filler[0]); hudSpritezm.SetAlpha(0.9f); hudSpritezm.SetBlendMode(AtomicEngine.BlendMode.BLEND_ALPHA); hudSpritezm.SetOrderInLayer(-3); }
public override bool TryParsePrefab(string text, out AnimationSet2D value) { throw new System.NotImplementedException(); }
public override void SetUrho(AnimatedSprite2D instance, AnimationSet2D value) { instance.AnimationSet = value; }
public override void SetPrefab(AnimatedSprite2DPrefab instance, AnimationSet2D value) { instance.AnimationSet = value; }
public AnimationSet2D(AnimationSet2D prevSet) { name = prevSet.name; _animationList = prevSet.GetAnimationList(); }
public void AddAnimationSet(AnimationSet2D animationSet) { _animationSetList.Add(animationSet.name, animationSet); }