Permalink
Browse files

Merge pull request #105 from JimMarlowe/JM-BFLY-1286

Fix both butterfly examples #1286
2 parents cfa4c4e + f8004ab commit 1c9cc28f64f6e5ff41a14db5d3d81d67adc6aa85 @JoshEngebretson JoshEngebretson committed on GitHub Dec 29, 2016
@@ -20,7 +20,13 @@ void Update(float timeStep)
for (var i = 0; i < 10; i++)
createButterflyNode(new Vector2(mousePos.X, mousePos.Y));
- }
+ }
+ else if (input.GetMouseButtonDown(Constants.MOUSEB_RIGHT))
+ {
+ var mousePos = input.GetMousePosition();
+
+ createButterflyParticle(new Vector2(mousePos.X, mousePos.Y));
+ }
}
@@ -38,6 +44,21 @@ void createButterflyNode(Vector2 pos)
}
+ void createButterflyParticle(Vector2 pos)
+ {
+ //project mouse screen position to the world position
+ var screenPos = viewport.ScreenToWorldPoint((int) pos.X, (int) pos.Y, 0);
+
+ //create particle emitter
+ var emitter = Scene.CreateChild("ButterflyEmitter");
+
+ emitter.Position2D = new Vector2(screenPos.X, screenPos.Y);
+
+ var pex = emitter.CreateComponent<ParticleEmitter2D>();
+
+ pex.SetEffect(GetSubsystem<ResourceCache>().GetResource<ParticleEffect2D> ("Particles/particle.pex"));
+
+ }
Viewport viewport;
@@ -3,6 +3,9 @@
// create a scene
var scene = new Atomic.Scene();
+// assign scene into global so it's not GC'd
+Atomic.Player.currentScene = scene;
+
// create an octree component
scene.createComponent("Octree");

0 comments on commit 1c9cc28

Please sign in to comment.