Spawn objects at viewpoint?

0 favourites
  • 9 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hey everyone!

    First of all, I am a total beginner and I am going crazy here :P

    I have been searching for a solution to this for quite a while and I have tried different solutions I have found in tutorials and different questions asked here in the forums, but none of them has made me satisfied.

    My question:

    I have a game where you can scroll the picture when touching the screen. So you drag and drop to adjust the viewpoint.

    When a certain thing happens, for example a global variable is triggered I want to spawn objects in the center of the current viewpoint. The layout is 6144 x 1536 and the viewport is 2048 x 1536 so it has to be in the center of the current viewpoint of the one playing my app, does this make sense?

    Also I would like the objects spawned, in this case balloons not to be spawned outside the viewpoint.

    And, lastly, is there anyone who knows how to increase the scroll speed when touching the screen? Currently I am using DragScrollX+DragMouseX-Touch.AbsoluteX & DragScrollY+DragMouseY-Touch.AbsoluteY and I dont really know how to increase the speed of scrolling.

    Is there anyone here that knows how to solve this? I would be so thankful for a response :)

  • Anyone? :(

  • you can always get to the center of the screen with system variables scrollx and scrolly

  • Colonel Justice Thanks a lot. The camera scroll was really good! Btw, I would like to do it so that when I touch a specific object the scroll should be turned off and when I'm not touching it it should be turned on again. Because when the scroll is active and I want to touch a character on screen it might sometimes be registered as a scroll instead of a tap, does this make sense?

    The balloon solution is super nice. I did not think of creating an object at scrollx. Since I wanted several balloons to be created within the viewpoint I tried random(scrollx-900,scrollx+900) and for Y i picked a value that is outside the layout because I want the balloons to float in. Works like a charm! Thank you so much!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • jobel I misread your solution first. But yeah, that is a great suggestion. I did not think of scrollx and scrolly, it worked like a charm! :)

  • Colonel Justice I ran into another issue here. Is there some kind of way to invert the way it's scrolling? As it is now when you drag to the right the camera moves to the right but i would like it to be the opposite. Is it doable?

  • Colonel Justice I ran into another issue here. Is there some kind of way to invert the way it's scrolling? As it is now when you drag to the right the camera moves to the right but i would like it to be the opposite. Is it doable?

    Set the angle of motion for the TouchController to Touch.AngleAt(0) + 180

  • Colonel Justice Thanks! I also found that the Reverse Custom behaviour worked :)

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