Pause Screen

391 views
Skip to first unread message

Daniela Lapa

unread,
Jan 14, 2012, 8:46:14 PM1/14/12
to melonJS - A lightweight HTML5 game engine
hello,
I wonder if anyone could help me out. I created a PauseScreen altough
dont really know how to call it. if I use the same logic as for the
other screens it, when returning to the game, will reset it..

Im a bit lost and believe there's a especific code for it but I have
no idea of what it is.. help? :\

Ellison Leão

unread,
Jan 14, 2012, 8:49:50 PM1/14/12
to mel...@googlegroups.com
I had one pause screen on my becoming game. You can use the code as an example

It's just a PAUSE text under a black strip. You can put this code under the var jsApp class



2012/1/14 Daniela Lapa <dan...@live.com.pt>

Daniela Lapa

unread,
Jan 14, 2012, 8:53:38 PM1/14/12
to melonJS - A lightweight HTML5 game engine
i need to make a screen on wich the user will have options, some sort
of shop where he can update his weapon.. im gonna take a look ate your
code and see if I can make it work. thanks! :)

Daniela Lapa

unread,
Jan 15, 2012, 5:44:03 AM1/15/12
to melonJS - A lightweight HTML5 game engine
well, im using this code. but still have the same problem.. it doesnt
resume the game

this is called when pressed the key Enter:
me.state.onPause = function () {
me.state.change(me.state.PAUSE);
};

I guess it's because im changing the state but otherwise how can I
reach the PauseScreen?

melonJS

unread,
Jan 15, 2012, 8:33:45 AM1/15/12
to melonJS - A lightweight HTML5 game engine

Actually onPause is a callback called when the game is being paused,
and the right way of pausing/resuming the game is to call the
me.state.pause or me.state.resume function :
http://www.melonjs.org/docs/symbols/me.state.html#pause

However, today when the engine in "in pause" objects are not anymore
updated or draw, so i don't think this would be the right way to go
for this kind of thing. I would rather specify a new screen and switch
to it when needed (then switch back to the game), or define an
"overlay" object.

Daniela Lapa

unread,
Jan 15, 2012, 9:28:26 AM1/15/12
to melonJS - A lightweight HTML5 game engine
but by doing so, how can go back to the game? if I change it like
me.state.change it will reset the game..

melonJS

unread,
Jan 15, 2012, 9:23:24 PM1/15/12
to melonJS - A lightweight HTML5 game engine

you can save state of the various stuff and restore it after but yes
this not the best way today to do that. that's why I was suggesting
to use an overlay object during the game. you could imagine to
instantiate a specific object on key press during the game that will
display your option and your small shop, and during that time stop
updating player pos and collision. would make sense to me as well.
Reply all
Reply to author
Forward
0 new messages