Defold 1.2.151 has been released

Thanks! :100:

4 Likes

How does this work? I tried setting cursor property values but nothing changes.

playback_rate does seem to work fine.

function init(self)
	local num =  math.random(30)
	print(num)
	go.set("#sprite", "playback_rate",math.random(num))
end

Got it working

function init(self)
	local num =  math.random(30) / 30
	print(num)
	sprite.play_flipbook("#sprite", "spin", nil, {offset = num})
end

Has to be a value between 0-1? And has to be used on play_flipbook also it’s called offset not cursor. playback_rate can be set here too.

This is awesome! Really useful for spawning things on the same frame and giving them some random variation in animations. :slight_smile:

4 Likes

There is more information in API documentation: https://www.defold.com/ref/sprite/#sprite.play_flipbook:url-id--complete_function---play_properties-

3 Likes

I haven’t had time to use it myself, but setting the cursor and playback_rate properties should work?
(Let’s ping @sven who implemented it)

4 Likes

You’re right they both do work with go.set I just wasn’t setting cursor in the normalized 0-1 range.

go.set("#sprite", "cursor", 0.5) -- works
6 Likes

Me after reading this :

7 Likes

What exactly is the flipbook cursor for? I have looked at the documentation but don’t understand what it is for.

2 Likes

It lets you choose which frame of an animation to set the sprite’s animation to in code. So if you do #/total frames you can select a specific frame.

go.set("#sprite", "cursor", 0/30) -- starts animation on first frame

This is useful because if you have say birds with flipbook animations and you want to spawn them on the same engine frame you can set their cursor/offset randomly so that they are not all playing the animation in the same exact way. You could add extra random playback speed to get each bird even more personality.

Previously to get similar effect we had to add multiple animations to the same atlas which started and ended on a different section of animation loops. Now it’s much cleaner.

There are other application as well, such as temporarily setting the animation speed super low for paralysis effects for example.

10 Likes

I understand now. Thanks!

2 Likes

So the most basic use case I needed it for are the wind affected objects:

Moreover, the speed of a hero in an RPG game could be leveled up, so it’s nice to also increase the framerate of the running animation in parallel with increased movement speed.

Next, I could now check what frame of the animation attack is actually playing and apply some effect then, for example in the frame when the sword hits the mob the mob should play a hurt animation and the damage should be calculated and displayed above the mob, and even some particlefx could be played in that particular moment!

We are going in the direction where we could animate almost anything and it gives developers infinite possibilities! :star_struck: It’s great! :smiley: Thank you very much!

10 Likes

P.S. On my Opera browser the movies are unavailable on the forum :frowning: Works in Chrome and Edge.

2 Likes

Awesome, thanks! I know it’s way past time I learned to use gitHub, but messing around with external apps to do this gives me a headeache when all I really need is a convenient way to copy the latest version to a different computer and Defold’s inbuilt tools are good enough for that.

I’ll get there eventually, but until then the download link is going to be really helpful.

2 Likes

@Oleg_The_Evangelist Video suggestion: using cursors in animations :smiley:

6 Likes

It is available in the editor you can download from the Dashboard. If you’re not seeing the new Toggle Assets Pane menu item under the View menu, and you’re not seeing an Update Available notification, you might have ended up on the “stable” release channel. The “stable” release channel currently does not actually mean “more reliable” as you might expect. It only means that you’ll get very infrequent updates to the editor. To get back to frequent releases, you should re-download the editor from the Dashboard.
@gianmichele

3 Likes

Thanks for this info on API.

1 Like

Thank you again very much for this feature, Defold Editor is now super comfortable to use :wink:

4 Likes

like the usual way when we read our own docs on the video, or something else? Since this is really just a single API call… Unless I am missing something :wink:

1 Like

Even though I wouldn’t mind hearing you read the docs again, I was thinking more about seeing some examples/use-cases for it, since I for one, have no idea what to use it for even though it’s just a single API call.

1 Like

I talked to @sven about it. He has a “non-pretty” demo and a nice solid backlog of other things to do. So I suggest we take a usual approach here - wait and see if Sven has time to make his demo project ready for the showtime, or mb @benjames171 or somebody else just utilises the feature in one of their open source games.

Makes sense? =]

3 Likes

Yass :sunny:

1 Like