Problems with ViewportTop

Get help using Construct 2

Post » Wed Feb 12, 2014 5:17 am

Hi, I'm trying to reverse engineer the Space Blaster example to learn how it was created. I'm having some trouble with the viewport code (i.e. testing using ViewportTop("Game")and ViewportBottom("Game")).

I'm trying to debug the code, and when I try to set the contents of a textboxt to ViewportTop("Game"), it doesn't set it to anything. Does any one know what I'm doing wrong?

I have attached a capx file below, and wondering if anyone can help?

dropbox.com/s/sqegh0dcm2milel/viewport.capx
B
3
Posts: 5
Reputation: 235

Post » Wed Feb 12, 2014 5:22 am

Your textbox isn't tall enough! Make it bigger/taller.
ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Wed Feb 12, 2014 5:27 am

Oh wow, thank you so much, that solved the problem!!
B
3
Posts: 5
Reputation: 235

Post » Wed Feb 12, 2014 2:24 pm

Could I ask a follow-up question - I'm trying to create the effect when an EnemySpawner sprite comes "onto" the screen (EnemySpawner.Y >= ViewportTop("Game")?).

However, I'm having trouble with the for-each loop (line 14, Event Sheet 1). If I see the preceding condition (line 13) to time > 0.5, then none of the following code is called. If I set the preceding condition (line 13) to every tick, then the following conditions are all called (because ViewportTop("Game") is mysteriously set to 0).

I have attached a capx file below, and wondering if anyone can help? Can I ask why there is a difference between time > 0.5 and every tick (I assumed that both conditions will be called multiple times?)? Secondly, is there a way to call the for-each loop multiple times so I can keep testing the condition (EnemySpawner.Y >= ViewportTop("Game") until it is true?

dropbox.com/s/tzb61wdexjlazgh/viewport2.capx
B
3
Posts: 5
Reputation: 235


Return to How do I....?

Who is online

Users browsing this forum: irina, Klarner and 28 guests