(solved) Help with object.Move

Started by etabeta, Tue 03/01/2012 23:49:56

Previous topic - Next topic

etabeta

Hi,

I'm a real beginner, stuck over a quite easy problem. I have the script for my game and the first cutscene involves a ship crossing the ocean. I've imported the sprites for all frames, then made a view with 4 loops and created room 1.
The player character is there but set "not visible".
I've read and seen all tutorials and according to my understanding I've written in the room script:

function room_AfterFadeIn()
{

object[0].SetView(1, 1, 0);
object[0].Move(7, 272, 3, eBlock, eAnywhere);

}


object[0] is the ship. Nothing happens at all, the ship is standing still in its original position.
I'm quite sure I'm missing something but after three days of reading about it I'm about to give up...!

Thanks a lot for your much appreciated help.

Khris

First, something unrelated to your question: you don't need to use Object.SetView() before moving an object (unless you want to change the appearance of the object, which doesn't make sense since this is the first thing that happens in your game so you'd set the sprite in the editor)
If you want to animate and move the object at the same time, you have to call object[0].Animate(..., eNoBlock, ...) before calling .Move, although it's probably easier to implement the ship as a Character in that case.
Also, in a room script, you don't need to use the object[] array, you can use its own name. (oShip.Move())

on to your question:
What I guess is that you actually wrote all of this in the room script, right? As opposed to just typing the two commands inside the function (which was already there)?

The problem is that AGS doesn't know to call that function; is has to be linked to the room event. Open the room, make sure it says (Room; number X) in the dropdown menu beneath the tree, then click the thunderbolt icon. Now click on "Enters room before fade-in", then click the ... button to the right. This links and creates the function. Since in your case it's already there, AGS will only link it, i.e. put its name in the empty field next to the event name.
If you do this for another event, AGS will use the default name, link it and create the function.

This general process is of course explained in AGS's tutorial, in Part 3, hotspots and events.

etabeta

Hi Khris,

that's great, thank you very much for you help. It's much clearer to me now (and the ship is moving too!).

Cheers

SMF spam blocked by CleanTalk