Can't get object to animate (solved)

Started by rodriguez1222, Thu 15/09/2005 21:53:07

Previous topic - Next topic

rodriguez1222

I hate to post this because I know I'm overlooking something, but here goes.

I've been trying to animate a sparkling book.Ã,  I want the animation to play as soon as the player enters the room and for it to simply loop continuously,
Yes, I have read the manual, done the tutorials, and scanned the forums for almost two days now before finally breaking down and posting.

So far I've tried the following:

function booksparkle() {
object[0].Animate(6, 0);
}
(Which does nothing at all)

function booksparkle() {
Object[0].Animate(6, 0);
}
(Which tells me "[" is already defined)

function booksparkle() {
Object.Animate(6, 0);
}
(tells me I must have an instance of the struct)

Object.SetView(6, 1);
Object.Animate(0, 3, eRepeat, eBlock, eBackwards)
(which tells me "Parser error: Unexpected 'Object'")

Yes I know this has been covered but I was unable to find a thread with a solution other than simply refering to the manual which is where I got the examples above.Ã,  All of which were entered into the room setting "{}" script.

Etcher Squared Games

I'm just learning 2.7 myself, but your first example was very close....

Code: ags

function booksparkle() 
{
Ã,  object[0].SetView(6);Ã,  Ã, // or whatever
Ã,  object[0].Animate(6, 0);
}


Objects need a view set first before any animation can be done.

The second one is invalid I'm guessing because Object is the "class type" not an actual instance of an object (geek speak)

The third example is flawed for the same reason.

And the 4th example again for about the same reason.
I'm sure Strazer can give you better details.

Why aren't you doing...

Code: ags

Ã,  oBook.SetView(6);
Ã,  oBook.Animate(6, 0);Ã,  // whatever the name of your object is



?
website: http://www.etcher2games.com/
email: etcher2games@yahoo.com
forum: http://www.etcher2games.com/forums

Anyone want to make my website for free?

SSH

my guess would be:

object[0].SetView(6)
object[0].Animate(6, 0);

assuming that you object is object 0 and your animation is in view 6, loop 0

oh, and Worm III beat me to it  :=
12

rodriguez1222

#3
thanks for the response, I appreciate it.

I did:
oBook.SetView(6);
oBook.Animate(0, 1);

(my sprite is in View 6, Loop 0)

I got an error stating: Parser error: unexpected 'oBook'

the object's name is Book, script name is BOOK, script o-name is oBook

Tried this too:
oBook.SetView(6);
oBook.Animate(6, 0);

Same error

Etcher Squared Games

Ok....
1. let's see the entire function where this code is....
2. Where does this code live?  in room script? in global?
3. Where do you USE this function?
website: http://www.etcher2games.com/
email: etcher2games@yahoo.com
forum: http://www.etcher2games.com/forums

Anyone want to make my website for free?

rodriguez1222

The entire function:

function booksparkle()
{
oBook.SetView(6);
oBook.Animate(6, 0);
}

The above script is in 'Room Script'

As far as where its used, is there somewhere else I need to activate the function?  I was wondering that but didn't see the documentation for it anywhere, so I wasn't sure.
What I mean is, the function is in the room script, and the object itself is added to the room.  Right now I'm not getting any errors, but the book isn't animating either.

Thank you so much for the help.  I am very grateful.

Wretched

Are you actually calling the function from anywhere, e.g. from 'player enters room before fadein' ?

strazer

Quote from: rodriguez1222 on Thu 15/09/2005 21:53:07I want the animation to play as soon as the player enters the room and for it to simply loop continuously

Note that the default repeat setting for Object.Animate, if not specified, is to play the animation only once. If you want it to repeat contiously, you have to specify the optional RepeatStyle parameter, i.e.
  oBook.SetView(6);
  oBook.Animate(6, 0, eRepeat);

Also, are you absolutely sure that you want to play loop 6 of view 6 as specified above?
You may want to increase the delay a bit, otherwise the animation probably plays too fast.

rodriguez1222

fixed one part... it was actually supposed to be:

function booksparkle()
{
  oBook.SetView(6);
  oBook.Animate(0, 5, eRepeat);
}

What's the context for calling the function and where does it go in the script?

strazer

I'm not sure why the function is needed at all. Why not just put

  oBook.SetView(6);
  oBook.Animate(0, 5, eRepeat);

in the room's "Player enters room (before fadein)" interaction?

(Room editor -> "i" button -> Double-click "Player enters room (before fadein)" -> Choose "Run script" -> Click "Edit script..." -> Paste code)

rodriguez1222

ROFL  I didn't know that was there...

Wow, I feel sheepish.

Ok, its animating, thank you so much!

Now, how do I get it to stop when the mouse moves over the toolbar so the buttons can be pressed?

Again, thanks so much! 

strazer

The buttons are greyed out, right? That means the game is paused (blocked).
By default the animation is played blocking, pausing the rest of the game. You have to tell it to animate non-blocking:

  oBook.Animate(0, 5, eRepeat, eNoBlock);

rodriguez1222

Awesome!

Thanks a bunch.  It's working perfect now.


strazer


SMF spam blocked by CleanTalk