Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by tcotav

The billboard entity is a way to trigger and throw up a wall on which to write text. I needed it for tutorials in my game. Here's what it looks like:

/><br />
<br />
There were two basic requirements for it:<br />
<br />
1) the aforementioned text-writing to tutor the players.<br />
2) game pausing while the billboard is present (so that the baddies don't kill you while you read).<br />
<br />
The <strong>major constraint</strong> is the use of a static image for the billboard.  This means that all text has to be altered/tweaked to fit. <br />
<br />
The code is available here:<br />
<br />
<a href=https://github.com/tcotav/blackboard_impactjs/

1 decade ago by Hareesun

That is very cool.

You could always use straight up canvas drawing functions to draw the frame. That way you can have it any size and resizable without too much hassle. :)

1 decade ago by sleenee

Nice entity! But indeed, scalability is a huge issue since text will often vary alot. (at least in my game)

I modified the notification manager plugin (can also be found on this forum under code) so it would have a white background so the text would be visible at all times (I do still have layer problems, it's not visible when it's on the same spot as a layer that would come before the entity that spawns the wordballoon). But indeed: I have no frame around the white square (or rectangle, depends).

Hareesun, if you could you give us a code example of how you would solve this? That would be great!

thanks in advance!

Sleenee

1 decade ago by tcotav

I went back in and updated this entity using the direct draw to canvas as Hareesun suggested.

Gone is the graphic for background replaced by two drawn rectangles.

I also made it so that text could be input in bulk and the javascript would reflow properly in the space provided.

1 decade ago by yatayata

hi -

trying to use this, but on mobile...

* enter key doesnt work
on mobile devices. can you set up the billboard to close on click?
then we probly need a button somewhere inside the object?

* positioning
would be nicer to be able to be dragged around i think

* hard to position in editor
since it obscures other stuff.

* game still runs
// flip this boolean in game -- this pauses all activity
ig.game.fBillboardPause = true;
this code seems to have no effect?

1 decade ago by tcotav

Hi yatayata,

Regarding positioning and moving, I designed this specifically to be in the center of the screen (kind of like a storybox in an RPG) rather than as a floating dialogue box. There are two other project/code samples listed in the forum that does something more in line (I think) with what you're trying to do:

http://impactjs.com/forums/code/simple-notification-with-context
http://impactjs.com/forums/code/extending-notificationmanager

I'm not trying to punt with this of course. To make my code do what you're asking would require mapping of coordinates into the game coordinate system. Right now, I dodge that by making the bb entity relative only to the current canvas.

Answering your other questions in case you'd like to continue using this regardless...

Custom click on close is something that can be done relatively easy by modifying the main.js code sample that is included on git and that you put into your own main game javascript file. Specifically in the update() method, change line:

if(this.fBillboardPause && ig.input.state("space")) {

Also, if you don't have this code in your main game js file's update loop, your game will continue to run. Maybe that accounts for that?

Weltmeister Monster -- yeah, that was a legacy of the old way I did this (where I had an entity that was THAT big). The positioning of that entity in the weltmeister doesn't matter to layout anyway, so I'll just scale that down in the source code. What I did was just push it off to the edge of the level (again because its location wasn't used in-game).

1 decade ago by Miggy

Very Cool!


Visit this : steelart.ph
Page 1 of 1
« first « previous next › last »