panning a view port window not entire layout

  • trying to do something like the way starcraft does and I've seen another html 5 based game that does it with JavaScript so I know its possible just figuring out how to do it construct is eluding me.

    I have 2 layers one is my "HUD" which has a sprite entire game size with a transparent "window" cut out, second layer has a tiled background 100 times the size of the game layout.

    trying to get where I can drag the tiled background around but constrain it to the "window" of the sprite HUD.

    I tried the drag&drop 2 with boundary plugins but then it makes it so I can't drag the background past the sides at all

    thanks for any help

  • never mind I figured it out had to set the boundary left right top and bottom based on the layout co-ords and not my HUD sprite took some math to figure out the x and y for each but it works

  • Any chance you can share a sample CAPX of the behavior you have come up with? I am very interested in the method used. Or maybe just a screenshot of the event sheet.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • there are no events involved just rex's boundary behavior applied to the tiled background.

    basically its all math so what I had to do was add a tiled background mine is 89000 x 52000 (i know its huge but its for a 800x800 map grid and each grid is 110x65 pixels) and add the boundary behavior.

    find the pixel point of the top and bottom of the window

    mine was 33 and 539

    the 33 is the bottom. add them together (572) subtract that from the background height (51428) enter that as a negative number for top (-51428)

    find the pixel point of the left and right of the window

    mine was 22 and 866

    the 22 is the right. add them together (888) subtract that from the background width (88112) enter that as a negative number for left (-88112)

    enter the numbers into the top, bottom, left and right properties for the boundary behavior on the tiled background.

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