Hello,
I have an animation view of an explosion for a specific object. Everything is scripted and functionally works, but the animation view is offset from the object. The object is called oPredator and here's my code:
if (bCheckCollisions == true)
{
// EXPLOSION
if (oHellfire.IsCollidingWithObject(oPredator))
{
//Display("KABOOM");
//ShakeScreenBackground (int delay, int amount, int length)
ShakeScreenBackground(5, 15, 20);
oPredator.StopMoving();
//oPredator.Visible = true;
oHellfire.Visible = false;
oPredator.SetView(4);
oPredator.Animate(0, 5, eOnce, eNoBlock, eForwards);
// Stop moving the missile
moveHellfire = 2;
}
}
For some reason, the animation of the explosion appears in a different location from where the oPredator object is. Any idea how I can make the animation centered over the oPredator object? Thanks,
-Reid
That can only be because the sprite of the animation is wider. Also remember that the object's position always is the lower-left corner.
Quote from: NsMn on Fri 11/09/2009 21:53:48
That can only be because the sprite of the animation is wider. Also remember that the object's position always is the lower-left corner.
I think that's it. The sprite animation frames are 318x318 and the Predator object is 128x33.
Anyway I can offset this? One idea I have is to change the view of the predator to the explosion view, making sure the first frame is clear. This will make it look like it disappeared. Then, I move the invisible predator object to a new location (offsetting from where it was) so that when the animation plays, it looks like its centered on where it was.
Is there an easier way? Somehow reset the animations' origin?
Found the solution using my below idea. Consider this solved! Thanks for the insight NsMn.
Quote from: Sparkplug.Creations on Fri 11/09/2009 22:08:18
Quote from: NsMn on Fri 11/09/2009 21:53:48
That can only be because the sprite of the animation is wider. Also remember that the object's position always is the lower-left corner.
I think that's it. The sprite animation frames are 318x318 and the Predator object is 128x33.
Anyway I can offset this? One idea I have is to change the view of the predator to the explosion view, making sure the first frame is clear. This will make it look like it disappeared. Then, I move the invisible predator object to a new location (offsetting from where it was) so that when the animation plays, it looks like its centered on where it was.
Is there an easier way? Somehow reset the animations' origin?
you can try using lockviewaligned or lockviewoffset, i believe. lockviewaligned will keep the the animation views with the regular view aligned, and you can set it to align to the left side or right side. lockviewoffset you can shift the animation view however many pixels in the x and y direction you want.