How do I draw Tilemap outside viewport using Paster?

0 favourites
  • 6 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi everyone,

    I am trying to set a split-screen using the Paster addon for a two-multiplayer platformer

    construct.net/en/tutorials/grappling-hook-example-capx-splitscreen-play-659

    It worked in first place but the issue comes when I try to draw the Tilemap outside the viewport limit. The screens created with Paster only show the tilemap inside the viewport. Objects and sprites doesn't have this problem.

    May anyone give me some help?

    Thanks, regards.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The tilemap object will only draw tiles onscreen. So the workaround is to move the tilemap, paste it then move it back.

    So maybe something like:

    Start of layout

    — set oldX to tilemap.x

    — set oldy to tilemap.y

    Every tick

    — tilemap: set x to self.x-player.x+scrollx

    — tilemap: set y to self.y-player.y+scrolly

    — parser: paste tilemap

    — tilemap: set position to (oldx, old.y)

  • Hello there R0J0hound,

    First of all, thank you for taking your time to try to solve this issue and give me a hand.

    Now I have a few questions about the tilemap position. What do you mean exactly with "Oldposition"?

    This is the event sheet I had in the first place. The objects which are pasted are HUD elements, players and other sprites. 'Scenario' and 'Background' are tileset and you can see they are positioned beside one another filling the viewport.

    Something like this?

    Sorry if I make some dumb questions but I barely know about Construct and programming.

    Regards!

  • Oldx and oldy would be variables you'd use to store the old position of the tilemap. They could be global variables or instance variables of the tilemap. You just have to define them.

    Other than that, yeah those are the actions to position the tilemap onscreen. Except the order you do those actions is important. You need set the position of the tilemap first before pasting. Then you'd need to move the tilemap back afterwards to it's original position. Thinking about it i did forget a step, the paster object needs to be moved too.

    So here's variety of the above working in the same way as your events. Instead of storing the old position it stores the position difference, and moves stuff back and forth by that.

    global number dx = 0
    global number dy = 0
    
    every tick:
    -- paster: clear to rgba(0,0,0,0)
    -- paster: set position to (player.x, player.y)
    
    //comment// actions to paste tilemap
    every tick
    -- set dx to palyer.x-scrollx
    -- set dy to player.y-scrolly
    -- tilemap: set position to (self.x-dx, self.y-dy)
    -- paster: set position to (self.x-dx, self.y-dy)
    -- paster: paste tilemap
    -- tilemap: set position to (self.x+dx, self.y+dy)
    -- paster: set position to (self.x+dx, self.y+dy)
    
    every tick
    -- paster: set position to (120,120)
  • Wow! It really worked! Thank you a lot.

  • do you have a CAPX???

    I could not do it

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