Dragging Actor Across Multiple Rooms - One Scene
Hello, if you can help me figure this out, please do. I would greatly appreciate it. Thanks.
(By the way, this is for a click and point game, not a player inside the game, so I am actually dragging an object.)
I have one scene with two "rooms" in the background. This means I have made the background display wide enough for them, so only one is on screen at a time. When I move my mouse to the right while holding the button down, the background advances so I can see the other "room to the right.
What I want to do is drag my actor with my mouse button over to that side and have the camera scroll over there. I can do it, but my actor gets caught at the edge, and I lose him. He won't go with me. How can I fix this? I want to take an actor without putting him into inventory and just carry him to a new location into the scrolling background.
Here is my code for the actor that scrolls the camera to the right:
Actor receives event/mouse button/is down
Attribute/game.Mouse.Position.X is greater or equal to 887.5
Interpolate Attribute: scene.Camera.Origin.X To: 1,000
Duration 1
Function Linear
Here is my code for my dragged actor:
Actor receives event/touch is pressed
Constrain Attribute: self.Position.X To: game.Touches.Touch 1.X
Constrain Attribute: self.Position.Y To: game.Touches.Touch 1.Y
I want to make him hang on. Do I need to respawn him over on that other side? And if I do, what is the code for wherever my mouse happens to be? Also, would he be respawned inside his rules or inside that wall rule? But please let me know if there's a way I don't have to respawn him.
Thanks.
Comments
Kind of like this?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks. Yours works great, but doesn't putting camera control on the object I drag make it so I can't do the same thing with another object I want to drag? For example, I want to drag a brush from the left side to the right. Then I want to move back again and take something else to move as well.
I thought camera control can only be on one actor in a scene? If I drag the actor across, I can't get back if I leave him.
If you include the control camera behavior in your drag rule, then the camera should follow the last object you dragged.
The Control Camera -- like other behaviors -- will trigger immediately if outside of any rules but will trigger according to a rule condition (such as When Touch is Pressed) when inside of a rule. So you can have Control Camera inside of multiple actors if each one is inside a rule that doesn't trigger when the other actors' rules trigger.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Wow, great! I'm so glad it's possible. Thanks.