YolkfolkThe Dizzy Fansite 2 logged in0 playing
Community discussion

Animation question

Started by Robbington on 15 December 2010 • 3,280 views

4 posts
#54853
Back again,

This time with a 'is there a better way of doing this' question.

In short I have a graveyard section in my game, just for asthetics I would like ghosts to appear and dissapear in the background.

I am using a collide object so that when the player enters the room the 'animation' is triggered

Ghost = ObjFind(1000);
ObjSet(Ghost, O_DISABLE, 1);
WaitFrame(100);
ObjSet(Ghost, O_DISABLE, 0);

Ect.

I've tried calling a similar function though UpdateRoom, but that doesnt seem to work, is there a better way of achieving this effect?

Ideally I would like a shimmer effect when they come and go, but I suspect that would involve creating a few more tiles, but after a few rubbish attempts I've decided to leave that until I am better at making the games.

Thanks again

Rob
👍 0
#72314

It depends if you want them called randomly or not. If so, it could be a bit complicated. Possible, but complicated.

regarding shimmering, you can fade them in and out instead. Put this code in your game:

/////////////////////////////////////////////////////////////////////////////////
// IN: int(fade 0..100)
// fade an object
/////////////////////////////////////////////////////////////////////////////////
func FadeObj( objidx, fade )
{
	color = ObjGet(objidx,O_COLOR); // get the current color of the object
	color = color & 0x00ffffff; // clear alpha component and keep only the rgb
	// compute a new alpha based on the fade value
	alpha = 255 * (100-fade) / 100;
 	color = color | (alpha<<24); // set the new alpha bits in the color
 	ObjSet(objidx,O_COLOR,color); // set the color back to the object
}

then call it when you enable the ghosts using FadeObj( IDX, fade ); where 'fade' is a number between 0 and 100, depending on how you want to fade it. Play around with it and see what you can do anyway.

👍 0
#72315
Nice,

Thanks for that. Gives a nice effect.

Not to worried about it being random, only got three ghosts in the room, so just a matter of timing so that they appear behind the trees and give a more spooky feel.

Rob
👍 0
#72316
if them being random isn't an issue, then calling them from colliders is probably the easiest way.

Oh and it's alex's code. I first used it in DWD way back in 2007!
👍 0