Page 1 of 1

How can I change block animation?

Posted: Tue Dec 20, 2016 6:43 am
by TotoShampoin
All is in the title...
Note : I use SMBX2 Beta 3

Re: How can I change block animation?

Posted: Tue Dec 20, 2016 6:48 am
by RPG_Magician
You gotta be a little more specific.

Animation as in the graphics? Or adding new frames to a block?

Re: How can I change block animation?

Posted: Tue Dec 20, 2016 7:14 am
by TotoShampoin
adding new frames and accelerate the animation speed... I've tried, but the editor bugs...

Re: How can I change block animation?

Posted: Tue Dec 20, 2016 7:26 am
by PixelPest
You can reduce the number of frames, but increasing isn't possible at this time. (There are a few ways you maybe could with LunaLua though)

Re: How can I change block animation?

Posted: Tue Dec 20, 2016 7:39 am
by TotoShampoin
:cry: I just wanted to do a NSMBU style level!

Re: How can I change block animation?

Posted: Tue Dec 20, 2016 8:29 am
by Emral
Instead of having their own individual animation timers, animated blocks are all bound to the same one, making the addition of extra frames impossible with conventional methods.

There is a way, but it requires a bit of coding effort.
The idea in this method is to make the block itself invisible and draw the graphic you want to use over it using Lua. There are Block Offset values for the bonking effect, making the recreation of the vanilla block animation possible.
Here's a short piece of code from one of my levels which draws a still image over blocks of a certain ID:

Code: Select all

local overlayIcon = Graphics.loadImage("overlayIcon.png")

function onDraw()
	for k,v in pairs(Block.get(176)) do
		local offset = v:mem(0x52, FIELD_WORD) + v:mem(0x54, FIELD_WORD)
		Graphics.drawImageToSceneWP(overlayIcon, v.x, v.y - offset, -65)
	end
end
You can use a different drawImageToSceneWP overload and add a timer in order to properly draw an animated image.