How can I change block animation?

Share and discuss custom SMBX graphics.

Moderator: Userbase Moderators

TotoShampoin
Goomba
Goomba
Posts: 3
Joined: Tue Dec 20, 2016 6:27 am
Contact:

How can I change block animation?

Postby TotoShampoin » Tue Dec 20, 2016 6:43 am

All is in the title...
Note : I use SMBX2 Beta 3

RPG_Magician
Snifit
Snifit
Posts: 216
Joined: Tue Sep 06, 2016 7:22 am

Re: How can I change block animation?

Postby RPG_Magician » Tue Dec 20, 2016 6:48 am

You gotta be a little more specific.

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

TotoShampoin
Goomba
Goomba
Posts: 3
Joined: Tue Dec 20, 2016 6:27 am
Contact:

Re: How can I change block animation?

Postby TotoShampoin » Tue Dec 20, 2016 7:14 am

adding new frames and accelerate the animation speed... I've tried, but the editor bugs...

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: How can I change block animation?

Postby PixelPest » Tue Dec 20, 2016 7:26 am

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)

TotoShampoin
Goomba
Goomba
Posts: 3
Joined: Tue Dec 20, 2016 6:27 am
Contact:

Re: How can I change block animation?

Postby TotoShampoin » Tue Dec 20, 2016 7:39 am

:cry: I just wanted to do a NSMBU style level!

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: How can I change block animation?

Postby Emral » Tue Dec 20, 2016 8:29 am

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.


Return to “Graphics”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari