Help with 'Bound to viewport'

  • Hey!

    Thanks for your support.

    I learned a lot of new (function) stuff today! :)

    So yeah, on my iPhone it works perfectly. The TimeText and Clock appear fine on iPhone. But that's probably because you can't drag 'outside' the screen. It will just end at the screen and store that TouchX and TouchY.

    I copied and pasted the code you wrote in your sample. The only thing I changed were a few minor things in the actions, but not conditions.

    Do you have any ideas where to look for to solve this last issue, or how to debug it.

    My project is portrait shaped, and has these settings:

    Hey man, you've been of great help, I really appreciate it!

  • Rudi55

    the problem would be after the you create the clock and timetext and compare the coordinates to the viewport. since timetext is pinned to the clock, make sure you are setting the clock's position.

    my sampled works, so there is some difference in your code (and not in the screenshots you posted).

    the viewport code must be a subevent from where the objects are created - otherwise they wont be picked, and the code will not be applied...

  • Hi, OK, sorry I didn't include the whole code in my previous post:

    Although I don't think it's in this piece of code either.

    I will continue to look. Thanks.

  • Rudi55

    yes, that code all looks fine.

    when I run my sample on my system with two monitors, I can release the touch way out side the viewport (like -1572) and the clock stays within the viewport.

    does my sample work for you? there must be some other place where the position is getting set...

    you could try running it in debug mode, which would let you see how many instances there are, what the coordinates actually are, etc...

    beyond that I would have to see all the code to figure out what is going on.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I might have found a clue.

    My project has these settings: 540, 960. My layout sizes are exactly the same settings.

    Now, I also have Scale outer applied. The 'visible' area in my game is 800 x 1388. That's the total size of the background, I covered the 'outsides' of that area with solid colored sprites matching the background.

    I do this because the objects spawn in under these sprites and move towards the centre of the screen, and I don't want them to be visible 'outside' the background.

    My reason for extending the background width and height is to adapt to different screen sizes (mobile, tablet) and that works fine in combination with Scale outer.

    Of course my browser on desktop doesn't 'see' any viewport since I covered it with sprites. So basically the horizontal viewport 'borders' don't exist. They extend way until the end of the browser window.

    Probably why it does work on mobile devices is because, I made the project so it fits on almost every phone/tablet, and constructed it so that the objects spawn in nicely at the extremes of most possible device screen sizes.

    I think it's working fine, it's just that I will have to adjust the coordinates somehow of left and right viewport based on how much the screen stretches or shrunk the game screen depending on the size of the monitor, and its resolution on desktop.

    So measure a 'fake' viewport only for desktop, probably using the width of the background image, since that will also shrink/increase and its borders are basically what I would want the viewport to be.

    Now this is a theory of course. What do you think?

    Sorry for the long post!

  • Rudi55

    OK! that makes it all clear now!

    I have run into that many times. The issue is you can't assume that the top left corner of the screen is 0,0. Normally I use scan outer to use the whole available screen, so I didn't consider that you would be masking off area outside the layout.

    if all your layers have parallax set to 0,0 then the layout will be centered on the screen. If any layers have the default 100,100 then they will be shifted over to the left...

    so since I don't know how your layers and masking sprites are set up, I adjusted my sample to use all parallax settings of 0,0. You can re-download my sample and now I think it does what you want.

    https://www.rieperts.com/games/forum/timetext.capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)