Engine Event Model - Documented anywhere?

Discussion and feedback on Construct 2

Post » Thu Feb 28, 2013 12:14 am

Hi everyone,

I'm new here, but I'm in love with this tool.

I'm having trouble, though, with finding things in the manual, because some of the terminology is overloaded.

For instance, I'm looking for the order that event callbacks happen in the core javascript framework that is used when we export a project called c2runtime.js.

The "events" as defined by Construct2 on the "System" plugin are
    On loading finished
    On end of layout
    On start of layout
    On canvas snapshot


I've hooked each one, and occasionally, it appears that "on start of layout" isn't firing in a timely manner, even though I certainly would expect it to. We may be "loading resources" and the engine is bogged down, but I don't see a "On start of loading", or an "On start of game". Scirra guys, this might be handy...

The Browser plugin has a few more that I've hooked
    On resized
    On went online
    On went offline
    On menu button
    On search button
    On update ready
    On suspended
    On resumed


and these seem to be fine, but none of them seem to happen as a 'start-up' event.



I thought I was golden with System."On start of layout", but sometimes it's several seconds before it actually fires. During this time, I see the layout with all the sprites on it, in their messy positions where I placed them while creating the layout.

What I'm hoping do to is execute a chunk of stuff PRIOR to the first frame of the layout being drawn on the screen, and only do it once. I want to do some interrogation of the actual window size, and hide/move some sprites and such out of the viewport before the user can see them, and I want to delete ones that don't apply. I have different sized buttons and such for devices with small screens and larger stuff for devices with bigger screens.

Can anyone offer any hints?

And, for the guys at Scirra, this really is an excellent product. You should be proud of yourselves.

-john




B
15
S
4
G
1
Posts: 15
Reputation: 1,339

Post » Thu Feb 28, 2013 1:03 am

'On start of layout' fires before the layout is drawn for the first time, and AFAIK it works fine. If you're seeing something else, post your .capx.
Scirra Founder
B
358
S
214
G
72
Posts: 22,946
Reputation: 178,333

Post » Thu Feb 28, 2013 6:26 pm

Do I post it here? Or upload someplace else and post a link?

How's that work in these parts?
B
15
S
4
G
1
Posts: 15
Reputation: 1,339

Post » Thu Feb 28, 2013 7:39 pm

Hi jgordos,
A dropbox account is recommended. See here:

http://www.scirra.com/forum/topic43676.html
B
51
S
13
G
8
Posts: 194
Reputation: 7,311

Post » Thu Feb 28, 2013 8:40 pm

Thanks, @Mulkaccino!

Sorry about all the newbie stuff.

-john
B
15
S
4
G
1
Posts: 15
Reputation: 1,339

Post » Fri Mar 01, 2013 12:50 am

Here's a link to the folder.

https://www.dropbox.com/sh/wjt17woiq51zsza/Gy3L8Pg84p

When it starts, the "Play" button is on the bottom of the browser window.

Resize the browser by hitting F11... Play comes up 10 pixels...

Hit F11 again to resize, and Play stays at the new location; go fullsize and it stays put.

It should be starting at 10 pixels from the bottom... But something about the viewport size stuff is inconsistent.

-john
B
15
S
4
G
1
Posts: 15
Reputation: 1,339

Post » Fri Mar 01, 2013 11:04 am

do you have scroll to player or set size ? I found that scroll to player does wonder but again im not sure on different size resolution. Also you could add the anchor function to the button?
B
7
S
2
G
3
Posts: 58
Reputation: 2,284

Post » Fri Mar 01, 2013 2:33 pm

Which browser are you using? Everything seems to be working fine in Chrome.
Scirra Founder
B
358
S
214
G
72
Posts: 22,946
Reputation: 178,333

Post » Fri Mar 01, 2013 11:01 pm

I use Chrome, too.

Here's what I'm seeing... Check my dropbox again.

https://www.dropbox.com/sh/wjt17woiq51zsza/Gy3L8Pg84p

In image 1_pressedRunLayout.png, you can see my entire desktop; The preview mode has started in Chrome, and the PLAY button is stuck to the bottom of the layout, just at the top of the black letterbox, and there's just a bit of the black letterbox showing.

In image 2_pressedRestoreDown.png, I pressed the restore down control in the top of the browswer (two overlapping boxes). You can see the window has resized, the layout has resized, and now there's a nice, fat letterbox around the entire layout. That's exactly like it's supposed to work, I'm sure. The PLAY button has now moved up a bit from the bottom (which is actually what I want. I'm looking to maintain that negative space, so this seems like "correct" behavior to me.

In image 3_pressedMaximize.png, I pressed the maximize control in the top of the browser. We're back to looking nearly exactly like image 1, except the PLAY button is now nicely maintaining that negative space at the bottom. By that, I mean it's no longer anchored to the top of the letterbox at the bottom. It looks great, frankly.

And from now on, it actually works like I want and floats nicely above the bottom of the letterbox, regardless of screen sizes. I've done this on several devices (iPad, iPhone, windows PC, windows surface, windows surface RT), and on the PC it seems to work the same in IE9 and Chrome, so it's very, very consistent.

But it's surprising to me, because the button's location is determined by a function I wrote; the default position for the play button is at the top left of the layout. You can see this in the capx.

Anybody have any ideas?

-john



jgordos2013-03-01 23:03:00
B
15
S
4
G
1
Posts: 15
Reputation: 1,339


Return to Construct 2 General

Who is online

Users browsing this forum: humanescape, shinichild, Yahoo [Bot] and 12 guests