Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Alen101 on Mon 21/12/2015 00:37:08

Title: object loop
Post by: Alen101 on Mon 21/12/2015 00:37:08
I have a map of a city and it would be great to put some cars and some clouds in it.
For that i have to make an object to move in a loop for the case of the clouds, and in the case of the cars make them to go from one point of the screen to ohter, then disappear and finally apear again in the first spot.
I cant manage to do it. :(
Any help would be great!!
Title: Re: object loop
Post by: Gilbert on Mon 21/12/2015 02:40:58
There are a number of ways to do this.
Below is a (probably not so good but) simple way:
Code (ags) Select

//Put this in repeatedly execute always of the room:
if (!object[2].Moving){
  object[2].X = 0; object[2].Y = 100;
  object[2].Move(640, 100, 2, eNoBlock, eAnywhere);
}
Title: Re: object loop
Post by: Cerno on Mon 21/12/2015 12:16:46
The Tween module might be worth your while.
I have no experience with it but from what I read, you can get smooth animations and it even supports easing (so you could make the cars slow down near an intersection).

I will probably try it out for the title screen clouds in Sibun (http://www.adventuregamestudio.co.uk/forums/index.php?topic=52733.0) (right now they are manually animated).
Title: Re: object loop
Post by: Monsieur OUXX on Mon 21/12/2015 16:42:16
Quote from: Gilbert on Mon 21/12/2015 02:40:58
There are a number of ways to do this.
Below is a (probably not so good but) simple way:
Code (ags) Select

//Put this in repeatedly execute always of the room:
if (!object[2].Moving){
  object[2].X = 0; object[2].Y = 100;
  object[2].Move(640, 100, 2, eNoBlock, eAnywhere);
}


I could be mistaken but I think that wouldn't work. Doesn't "Move" teleport the object instantly? Instead, as suggested, use the Tween module and recycle Gilbert's script by replacing "Moving" with whatever function offered by Tween to check if a movement is over, and replacing "Move" with "TweenPosition".
Title: Re: object loop
Post by: MiteWiseacreLives! on Mon 21/12/2015 17:30:16
No no, move works fine on objects.
Title: Re: object loop
Post by: Cerno on Mon 21/12/2015 19:13:52
Monsieur OUXX: Move just doesn't play the walk animation but still moves the object incrementally. To teleport, one has to set the x and y coordinates directly.
Title: Re: object loop
Post by: Alen101 on Tue 22/12/2015 04:00:31
It works fine unfortunately too quickly for my clouds.
I have installed the tween module but even the help file seems a bit dificult to me,

i dont know how to activate stuff, maybe is too advanced for me
any help would be great!
Title: Re: object loop
Post by: Gilbert on Tue 22/12/2015 05:22:46
Try to experiment with the speed parameter of the function until there is a value that fits you.
In particular, try a negative number.

From the manual(located at  Tutorial -> Setting up the game -> Characters, which unfortunately is a bit well-hidden):
QuoteThe "MovementSpeed" option allows you to control how fast the character moves when walking. Here, a larger number means he walks faster. If you find that a movement speed of 1 is still too fast, you can use negative numbers (eg. -3) which will move even more slowly. The lower you go, the slower the movement speed.

Title: Re: object loop
Post by: Alen101 on Thu 24/12/2015 07:39:28
Thanks, im making some loops already, thanks for all the help,
And im using both ways you told me, the tween and the normal one.

for example:

Code (ags) Select
object[8].TweenPosition(55.5,360, 17, eEaseInOutQuadTween, eRepeatTween);