glue something to the top of the screen?

Get help using Construct 2

Post » Wed Jul 31, 2013 4:58 pm

The anchor behavior cannot center sprites. Using events, I can center a sprite Horizontally Ok, but I cant do anything with it vertically, it just jumps around and goes a random Y, sometimes going off screen completely.

https://www.dropbox.com/s/opoehw830axlyc3/viewportYproblem.capx

The code I am using is this:

Browser On resized : mylogo Set Y to ViewportTop("lobby") + 27
                     mylogo Set X to (ViewportLeft("lobby") + ViewportRight("lobby")) / 2


I want to fix the logo 27 pixels from the top of the screen. It just doesnt work.

Any ideas why? I'm sure I used to do it like this.

Note: I have set the origin of the logo sprite to be X in the center, Y at the top. (i.e. origin x=width/2, y=0)
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Wed Jul 31, 2013 6:47 pm

I just tried your example in chrome. And it seems to work fine when you just resize the window. But if you maximize or minimize the window it looks like the browser-->resize is not called.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Wed Jul 31, 2013 10:27 pm

@cvp, did you resize vertically? If you resize horizontally (make it wider or narrower, its ok, but making the window longer/shorter leaves the sprite at completely random locations, some times off the screen at the top, sometimes half way down the screen. It only works if you make it longer/shorter really slowly and carefully. The same code for X (i.e. for horizontal movement) is fine, its just vertically that its hugely buggy.

In FF, I sometimes get a blank black screen also.

I just tried it in FF, and its just as buggy. Try making the browser longer quickly in jumps.

This bug used to be in Anchor, many versions ago (99?) which is why I dont use it any more. Until now, setting the Y manually has worked instead.

If i change the project to set Y every tick, its fine, but doing operations every tick like this will affect performance.

I suspect that its the Browser On resized which is the problem - its missing re-size events for what ever reason.nutmix2013-07-31 22:32:22
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Fri Aug 02, 2013 4:49 am

I tried this out and the logo stays where it starts always. (vertically)
I'm using FF version 22.0
B
5
Posts: 26
Reputation: 277


Return to How do I....?

Who is online

Users browsing this forum: LaroTaio and 3 guests