Adam's Lair Forum

game development and casual madness
It is currently 2017/04/25, 10:44

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 59 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
PostPosted: 2015/03/14, 20:16 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 821
Location: Italy
Role: Hobbyist
BitteWenden wrote:
How to adjust the GUI to the screen resolution? For example if I want my textbox in the upper-left corner of the screen no matter what screen size the user has.


Well, for this you have 3 possible solutions that I can think of:
  1. Manually fix the Widget's Position during the update phase in order to keep it in the desired position - works everywhere
  2. Add the Widget as a child GameObject of your Camera - but in this case you would be fixing its position relative to the Camera itself, independently of the resolution.
  3. Set it to be drawn in ScreenOverlay mode - but this works only if you want to keep it fixed relative to the upper-left corner. Otherwise you still have to manually adjust the position by hand.

_________________
Come on Duality's Discord channel. It's entertaining and productive! :mrgreen:


Top
 Profile  
 
PostPosted: 2015/03/14, 20:48 
Novice Member
Novice Member

Joined: 2015/03/06, 18:02
Posts: 20
Role: Hobbyist
What is the ScreenOverlay mode? If i set my GUI object to this mode it doesn't show up.


Top
 Profile  
 
PostPosted: 2015/03/14, 20:58 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 821
Location: Italy
Role: Hobbyist
Simply said, it's basically a second pass in the Draw phase where Components that are marked as ScreenOverlay are drawn.
In this pass, there is no parallax, and the origin is set to the top-left corner of the screen. Z starts from 0 and increases as stuff gets drawn "behind".
Quite useful to draw various UI elements and overlays to the Scene.

If you don't see your items, it's probably because you have to adjust their Position :)

EDIT: it's all vanilla Duality stuff, it's not made by me :mrgreen:

_________________
Come on Duality's Discord channel. It's entertaining and productive! :mrgreen:


Top
 Profile  
 
PostPosted: 2015/03/14, 21:06 
Novice Member
Novice Member

Joined: 2015/03/06, 18:02
Posts: 20
Role: Hobbyist
That's exactly what I wanted! Works! Thanks.


Top
 Profile  
 
PostPosted: 2015/03/21, 19:43 
Veteran Member
Veteran Member

Joined: 2015/02/12, 15:27
Posts: 104
Location: Lithuania
Role: Hobbyist
I was just about to come up with my own Particle Emitter, but you've already done that! :)

Is it possible to do something like firework effect with your emitter? I mean the effect when particles start from the center and the each particle moves in it's own direction. Or should I implement it myself?


Top
 Profile  
 
PostPosted: 2015/03/22, 00:02 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 821
Location: Italy
Role: Hobbyist
Deviver wrote:
I was just about to come up with my own Particle Emitter, but you've already done that! :)

Is it possible to do something like firework effect with your emitter? I mean the effect when particles start from the center and the each particle moves in it's own direction. Or should I implement it myself?

Ah, it's simple.. just use a FXPoint as the emitter's FXArea, with an InitialDirection of 0-360 (means particles can spawn in any direction in a circle) and, if you want, an InitialRotation of 0-360 as well.

Then, if you want to make a "firework" effect, I'd suggest to use around 100 particles (ParticlesAmount), with a fairly high MovementSpeed (it's in pixels/second - if you are at Z scale 1.. maybe 250-400?) and a short TimeToLive (0.3 - 0.7 seconds).

Anyway, just play around with the settings :D also they depend on your sprite.
Finally, if you want to have a real "firework" effect, set IsEnabled to false and call Emitter.Burst from code when you need it :)

Keep in mind that if you call Burst again before the effects of the first one finished (i.e. all particles are dead), it will re-initialize all particles - including those still around.

Let me know :mrgreen:

_________________
Come on Duality's Discord channel. It's entertaining and productive! :mrgreen:


Top
 Profile  
 
PostPosted: 2015/03/22, 09:53 
Veteran Member
Veteran Member

Joined: 2015/02/12, 15:27
Posts: 104
Location: Lithuania
Role: Hobbyist
So, tried your method, works quite nicely, but I've ran into an issue. Is it possible to know if the new particles are being drawn? It would be useful for me, because I want to dispose gameobject after the effect has passed. I solved this by a little hack and it works, but that just looks ugly.


Top
 Profile  
 
PostPosted: 2015/03/22, 10:09 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 821
Location: Italy
Role: Hobbyist
Uhm.. at the moment you can only know/set if an emitter is enabled or no. Didn't really think about checking also if there are particles still alive :D

Anyway it's quick to implement. Just give me a couple hours to test and put it on nuget :)

EDIT:
Well, it was easier than I thought :D
Now you can just check HasAliveParticles in the Emitter

_________________
Come on Duality's Discord channel. It's entertaining and productive! :mrgreen:


Top
 Profile  
 
PostPosted: 2015/03/22, 13:37 
Veteran Member
Veteran Member

Joined: 2015/02/12, 15:27
Posts: 104
Location: Lithuania
Role: Hobbyist
Woohoo :) Works like a charm! Thanks!


Top
 Profile  
 
PostPosted: 2015/03/22, 16:55 
Veteran Member
Veteran Member

Joined: 2015/02/12, 15:27
Posts: 104
Location: Lithuania
Role: Hobbyist
Not sure where to post this, so posting here.

I have a code like this:
Code:
      void ICmpInitializable.OnInit (InitContext context)
      {
         SpriteRenderer  _sprite  = this.GameObj.GetComponent<SpriteRenderer> ();
         ParticleEmitter _emitter = this.GameObj.GetComponent<ParticleEmitter>();

         _sprite.ColorTint   = new ColorsRgba(255, 255, 255, 255);
         _emitter.ColorStart = _sprite.ColorTint;
         _emitter.ColorEnd   = _sprite.ColorTint;
      }


I tried debugging it, it goes past _emitter assigning line and crashes with NullReferenceException on assigning ColorStart() telling that the _emitter is null. I can't figure out why it does not assign anything. I'm 100% sure the ParticleEmitter exists and that there is no external influence.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 59 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group