mrrossi's Recent Forum Activity

  • You're right - it's my fault! Realised this morning that I'd left the Drag & drop behaviour enabled from the previous method; that was messing it all up. Removed that behaviour and set the code back (without clamp) and it works.

    Brilliant, really appreciate the help! Only started with Construct 3 about 2 weeks ago now but I (think!) I'm getting a good grasp of it and can do about 90% of what I need to do now :)

    Cheers!

  • Hey guys... sorry, stuck again!

    The drag & drop map position from ROJO worked well, until I tried to scroll to a sprite, basically a map marker of where the user currently is. Want the map to start off centralised where the user is.

    For some reason, if I do that on layout load (even with a 0.5 sec delay) it messes up the edges and I then cant scroll far enough left, and it goes too far right...if its a manual button press action it works, but not well - if the sprite is out of the viewport it only scrolls to the far edge of the sprite.

    So, I tried the simplified calminthenight code from ROJO - works! Doesn't mess up the edges when I use "scroll to", and nicely puts the marker in the centre!

    BUT...

    That code doesn't restrict the edges at all, and you can scroll right off the map...

    I tried using clamp, and now have this:

    This does limit the scrolling but goes way off the edges still - I think it's to do with "scroll to"'s behaviour and the centre camera? The scroll to seems to put the sprite exactly in the centre of the view so is there another half distance x and y or something like that I need to factor in..?!

    TIA!

    Ross

  • Thanks again! I'd set Pin behaviour but not actually pinned the sprite to anything; now set an on layout start event to pin it to the background map - IT WORKS!!!

    Indeed, calminthenight’s solution was what I was going to try next so if I have any further problems will try / check out your simplified version.

    Thanks all!

  • Thanks again! Something has gone wrong with my original layout and/or event sheet - just created new ones and works perfectly!

    WELL... the map image scroll does...

    BUT it doesn't work as intended for the "town" sprites I want to scroll in place of the map - need to "bind" them somehow to the background map image or background layer, can't figure out how - any suggestions please? Changing the town sprite behaviours (Pin, Anchor, Scroll To, Bound to Layout, Drag & Drop) hasn't helped.

    Maybe I need to re-position the sprites relative to the background map sprite on each tick too...?

  • Thanks all!! I stumbled across the "drag and drop" behaviour method yesterday evening and have been tinkering; I've been using a check on every tick to see if the X and Y positions went beyond the borders (using negative values) and re-setting and this worked, but oddly not to the perfect numbers (0 and layout width/height - viewport width/height) - I was getting white borders top and right, and not scrolling far enough left and down.

    I've fixed this morning by tweaking the numbers (by 30 or so pixels each side) but didn't understand why!

    Just saw these posts... thought I'd try R0J0hounds "clamp" command (not come across this one before, thanks!) and unfortunately I get the same white border issue. I've checked my numbers again:

    layout 960 x 1708

    viewport 480 x 854

    -i.e. width and height wise it's half half / viewport is a quarter of the layout exactly.

    Background map image is exactly the same size as the layout.

    So... why the white borders?!

    Not a huge issue, as I can get by it with my checks & sets, be good to understand why though.

  • Great, thank you! I don't have a player as such; it's just a large map screen so I want the user to be able to drag around and see the far corners etc. But that could be helpful, I'll look into the offset values and see if I can get it to respond to the touch in the right way.

    Thanks also for the note about Anchor, I did read about that only yesterday but was looking at general sprite properties for another part of the game and didn't click that would be ideal for the buttons on this screen :)

  • Hi all

    I have a map screen that I want a user to be able to scroll around (on a mobile phone game). I've got a layout which is 4 times larger than the viewport, and set a background layer with my map image to this size.

    I've followed the tutorial here to use 8Direction and ScrollTo with an invisible sprite:

    construct.net/en/tutorials/add-smooth-scrolling-game-app-2292

    I don't really understand how this works to be honest! I've implemented it anyway... to get it to work (ish) I set the invisible sprite to be exactly the same size as the viewport (else it centres elsewhere and moves the background image so there's a white border), not sure if that's needed or I need to change the centre point or something... it only scrolls vertically (but I guess I can repeat for X values to make it scroll horizontally?) and carries on scrolling off the image (I guess I need to stop it somehow by checking a Y value?).

    It also scrolls pretty slowly. I tried increasing the x 3 number but that doesn't seem to make a difference.

    Is there another / a better / easier way to do this?

    I'd also want some fixed buttons / icons (i.e. sprites) overlaid on top of the map, they shouldn't move when the background map scrolls. Any pointers on how to do that also much appreciated!!

    Many thanks

    Ross

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok thanks, that does indeed sound clunky! I think the best way for me to do this will be to have a layer and a background image and then a second layer with individual sprites on it for the "buttons".

    Thanks both for your help :)

  • Thanks again. In this case, it will be easier to handle it slightly differently and use sprites.

    Just thinking of future examples though (and trying to improve my understanding of what is possible and what's not in C3), for example, if you had an image of a till, or a calculator. It'd be a pain to draw all the individual buttons.

    Is it possible to get the x,y co-ordinates of a mouse click / touch (will be a mobile app) in the event sheet? You could then carry out the action dependant on the exact location of the touch on the image (which would still be a sprite object, just a large one) - i.e. if x is between 10 and 30 and y between 80 and 100 you know that it's the area of the image that equates to the plus button, if it's another value its this button, etc etc?

  • Thanks lionz - yes I could do it differently. I need the user to see all the items, their price, how many are in stock and how much they have all at the same time, as there will be some maths involved... I could still do that though with one buy and one sell and the 8 items listed, with the user highlighting one.

    Anyway... is that a "no there isn't a zone feature"? I'm sure that's how I did it once many years ago - crikey, 28 years ago! , in AMOS Basic - you'd define clickable areas on the screen / your background image.

  • Hi all

    Hoping someone can advise as to the best approach here. I will have a "market" in my game where the user clicks buy or sell for approx. 8 different types of item. Should I create 16 sprites (buy and sell for each) and add events (to increase / decrease that product amounts and the players money amount etc) or can I use a single image and define clickable areas?

    I.e. it would be nice if I could draw a nice single image with all the buttons included and then define clickable zones that then respond accordingly, or does Construct 3 not offer a feature like that?

    Thanks!

    Ross

    Tagged:

mrrossi's avatar

mrrossi

Member since 27 Jan, 2023

None one is following mrrossi yet!

Trophy Case

  • 1-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

3/44
How to earn trophies