view problems

0 favourites
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template for top-down view games)
  • How do I make a camera scroll to layout edges with a static hud?

    basically I wan't to have the camera follow my player with a x and y offset

    and then my player is near the edge of the room the camera adjusts itself so the player does not go behind the hud

    Edit hey I can post I guess it wasn't to do with rep

    Edit again oops forgot urls can't be posted

  • I do stuff like this by having an invisible sprite called "camera" that follows my player wherever I want it to. I then set the game to follow that object, so you can just set up a few states in your game (like measure of player's position is within x pixels of layout edge) to know when to reposition the camera object relative to the player. I generally use lerp to move the object, too, so it isn't jumpy but remains smooth.

  • could you post a example equation?

    also would I scale the camera object to fit inside of the view square or would I make it the same size as the player?

  • Umm I should have one sitting around somewhere, but I'll try to whip something up. And the camera object is just the center/focal point with the "scroll to" behavior on it, so the size doesn't matter. If you want to zoom in/out, you would use layoutscale. You could set it with variables and such, but it'd be done with layout scale.

  • k thankyou

  • Here you go. I don't know where your UI elements are on-screen, so I just gave you the skeleton you would need to be able to reposition and zoom the camera however you see fit to avoid things. I turned unbounded scrolling to yes just to show solely what the camera code does. This is by no means a definitive or perfectly-featured camera for platformers, but it gives you a good starting point.

    Demo: Running in the browser

    Capx: Camera

  • I can't open it.

    are you using a beta version of C2?

  • Yes it's made in r211.

  • it not a platformer its a asteroids like game

    also what is the target for?

  • You never stated your genre (I can't guess), but the exact same principles apply to any type of movement. A platformer is simple way to showcase things. The target is to make it easier for you. Any offsetting or shifting focus can be done by just telling the target where to go and the camera object will automatically handle the movement for you. You also didn't say where UI elements were positioned on the screen that you wanted to avoid, so I just gave you the tools in that example to offset things however you need.

  • sorry

    the view is 640,480

    the hud fills the entire screen

    leaving a box for the view at the hud position of 222,76 with a width and height of 360

    I also don't want my camera to let the player leave the centre of it

    but have box for the view(not the hud) to stop at the Layout borders

    what state do you think I should use?

    Edit ya the hud is bouncing around

    and its anchored

    Edit Again: so right now I'm trying to...

    set the scroll to postion to...

    X: clamp(player.X-Xoffset,View.BBoxLeft,View.BBoxRight)

    Y: clamp(player.Y-Yoffset,View.BBoxTop,View.BBoxBottom)

    Xoffset being a global number of 82

    Yoffset being a global number of 16

    view being a object filling the view gap in my hud

    it does good except when I get to the edge of the screen it doesn't clamp the view to the edge of the layout

    it seems to be what I'm looking for though

    I'm just not very good at math

    just type this in at


    its the pic of my hud

  • C-7 better yet is there a 2d camera plugin for C2 that supports x y width and height?

    maybe multiple cameras too?

    Edit: or a way to off set the camera in this project depending on where the view is placed and its width and height?[/code:3tpsdbgk]
    here is a example of it not working
  • bump sorry

    but I've been waiting about a week now and I still need help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • bump can someone help me I still need this

    I want to make my camera system use 3 objects

    the hud the view and the player to indicate where the camera is positioned

    this right here ... .capx?dl=0

    it works if I don't need to modify the views position or size

    however I do so can someone take a look at this and write up a camera code I could use?

    Edit: basically a view port however I know you can't draw things to the screen in construct 2 so

    I need somebody's help for the math behind how it works

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