object loop

Started by Alen101, Mon 21/12/2015 00:37:08

Previous topic - Next topic

Alen101

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!!

Gilbert

There are a number of ways to do this.
Below is a (probably not so good but) simple way:
Code: ags

//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);
}

Cerno

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 (right now they are manually animated).
123  Currently working on: Sibun - Shadow of the Septemplicon

Monsieur OUXX

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

//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".
 

MiteWiseacreLives!

No no, move works fine on objects.

Cerno

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.
123  Currently working on: Sibun - Shadow of the Septemplicon

Alen101

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!

Gilbert

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.


Alen101

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
object[8].TweenPosition(55.5,360, 17, eEaseInOutQuadTween, eRepeatTween);

SMF spam blocked by CleanTalk