need spawning help from an experienced user

iDeveloperziDeveloperz Member Posts: 1,169
edited November -1 in Working with GS (Mac)
Hi everyone, with some help from VML, i'm doing a game but the cans wont spawn correctly as the camera goes up. When its the start of the game the camera is perfect but after it starts to move the pawn point is lower down from where the user clicks.

Comments

  • ORBZORBZ Member Posts: 1,304
    this doesn't ahve anything to do with spawning. it's got to do with world coordinates vs screen coordinates.

    what you need to do is add the camera offset to your touch x and y position.

    you can get the camera offset from a scene scoped actor. it's not available to prototype actors (why the hell not??!)

    so what most people do is create two game attributes called cameraOffsetX and cameraOffsetY (both reals)

    then in an off camera actor (usually called something like game controller or scene controller etc) you constrain the game attributes defined above to the scene camera offset x and y.

    that in essence "lifts" the camera origin x and y out of scene scope and up into global scope where all your prototype actors can see them.

    then add those offsets to any touch coordinates you are using to spawn your actor.

    touch.x + cameraoffsetx
    touch.y + cameraoffsety
  • iDeveloperziDeveloperz Member Posts: 1,169
    I dont understand. :(
  • firemaplegamesfiremaplegames Member Posts: 3,211
    If your scene is bigger than 480x320, you need to account for the camera offset.

    Create a global game attribute called CameraY.

    Create a new Actor called CameraTracker. A simple box will do. Do NOT put any code in the Prototype.

    Drag the CameraTracker Actor into the Scene, and place it just outside of view.

    Double-click on the CameraTracker Actor in the Scene and click the padlock.

    Add a Constrain Attribute behavior to the Actor:

    Constrain Attribute: game.CameraY To: Scene.Camera.Origin.Y

    Now, any time you spawn a new actor, you will add game.CameraY to the Y Position.

    So:

    Spawn Actor
    [new Actor]
    At: Touch.X, Touch.Y + game.CameraY
  • iDeveloperziDeveloperz Member Posts: 1,169
    Oh i see now. Sorry for being so dumb :(

    Can the camera tracker go anywhere outside the view? or on top of it, outside?

    Thank you for replying.

    Edit: Sorry I cant do it. VML did something that spawns the cans for me and i don't know whats what. :\
  • firemaplegamesfiremaplegames Member Posts: 3,211
    The CameraTracker actor can go anywhere. just move it out of the way so you don't see it.

    You're not dumb.

    Dig around in the code, you should be able to find the Spawn Actor behavior somewhere. It might also be in one of the instances on the stage.
  • iDeveloperziDeveloperz Member Posts: 1,169
    I cant really explain. Sorry i am so bad at Game Salad. I just don't have any time to go on it. With my Exams and everything. Anyway. The spawning is done.

    Imagine you have an iPad and your holding your finger down. - A 50% Opacity can appears. When you let go it goes 100% and (By changing actors). Whilst its 50% you can drag it around by the way. So you just let go and the new actor fell until it collides with the table at the bottom. Now you keep on adding cans. When it moves up. You go to click the screen but the can spawns say 100 pixels below where you spawned. To be honest I cant explain. I can send anyone the built version for Mac OSX. if you email me... ideveloperz@me.com

    Once again i'm sorry for being stupid. :(
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You're not being stupid. You're asking help for a mobile game you're making! I can't imagine that there's too many kids asking similar questions!

    And I understand your spawning issue.

    But trust me, you need to do what ORBZ and I mention above. You need to account for the camera offset. Perhaps VML can help you with it.

    You have to add the distance that the camera has moved to your Spawning position. Or the can will appear in the wrong place.
  • iDeveloperziDeveloperz Member Posts: 1,169
    Oh i see now what needs to be done. Thank you for the help. Ill ask VML what he's done. :)
  • iDeveloperziDeveloperz Member Posts: 1,169
    I found out how it works now. and changed it but it still is not working. Here is what keeps on happening.

    image
  • iDeveloperziDeveloperz Member Posts: 1,169
    Ok so the way i spawn is

    when touch is pressed
    spawn actor:
    Can overlay
    Direction 0 - Actor
    Position game.touch.touch1.x _ game.touch.touch1.y

    This is one an invisible actor that covers the whole iPad screen.
  • iDeveloperziDeveloperz Member Posts: 1,169
    This is how the can is spawned. So what Am I doing wrong?

    image
  • firemaplegamesfiremaplegames Member Posts: 3,211
    So again, you NEED to account for the camera offset. The distance that the camera moves up.

    Your spawn Rule needs to look like this:

    when touch is pressed
    spawn actor:
    Can overlay
    Direction 0 - Actor
    Position game.touch.touch1.x _ game.touch.touch1.y + game.cameraY <----- YOU NEED TO ADD THIS

    Follow my post above about creating a cameraTracker actor or it will not work.
  • VmlwebVmlweb Member Posts: 427
    I found the problem
    When the CanOverlay was being created it was constraining it to touchY instead of touchY+cameraOffset
Sign In or Register to comment.