Put an image (actor) in a status bar

yogyog

  • Posts: 24
Hi - first off, stencyl is a great program, and makes game-making really easy!  I don't have it working on Linux yet, but it runs fine in XP, and I've started making a game called Mundane Game.

So - I have a 4 way scrolling playfield, and you collect objects.  There's a ready-made function for that, and it shows the number of objects yet to collect in the corner of the screen.  The only problem is it doesn't tell you what this number is!  The obvious thing to do seams to be to stick an image (I suspect an actor) next to the number to tell you what it is.  Is there a way to do this?

ShivaFang

  • Posts: 248
There's 2 ways I can think of off the top of my head, and depending on what you prefer either way could be arguably 'easier' than the other.

Either way, you'll want to create an extra actor with the same image/animation as the item you want to collect (I'ma call this 'collect Icon' in my screenshots') it will have no behaviours or anything else.

(I have not *tested* this.  It *should* work but there may be kinks that need to be ironed out)
Basics
1)  In your behaviour that shows the number of objects on screen, create an Actor Attribute, I'm going to call this 'DisplayActor'
2)  In 'when created' put the following;
    -create [DisplayIcon] at x:0, y:0 at front
    -set DisplayActor to [Last Created Actor]
3)  Now, depending on what you want to do, follow either the 'Draw Method' or 'Actor Method' procedure, below.  (Personally, I'd use the 'Draw Method', but there's a bit more code with it).  Do ONE or the OTHER, not both!

Draw Method
4)  at the end of your 'when created' for the number displayer add;
  - [hide] Sprite for [DisplayActor]
5)  In your 'when drawing' for the number displayer add the following right after where it prints the number of collectables left;
  -  Move pen [to] x:-32, y:0  (fiddle with these numbers until you get it where you want it)
  -  draw image for [DisplayActor]
6)  If you do any more drawing in this behaviour, that's it, otherwise put a Move Pen [to] x:0, y:0 otherwise all your drawing will be off a little.
Done!

Actor Method
4)  Change your 'create [DisplayIcon]' so that the X and Y values are where you want it.
5)  At the end of the 'when created' section add the following;
   -  send [DisplayActor] to layer [whatever layer is your 'top' layer ID]
   -  Anchor [DisplayActor] to screen.
Done!  (I think, not as sure about this method)

I'll post this as-is for now, give me a second and I'll post pictures of the block arangments.

EDIT:  Here's what the blocks look like - note that you'll have to change things to suit your specific project (layer numbers etc)

« Last Edit: May 21, 2012, 09:26:18 am by ShivaFang »
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!