Giter VIP home page Giter VIP logo

Comments (1)

slyddar avatar slyddar commented on August 10, 2024

Actually I did get it working using this exact method. Guess it might be something you could add to the main branch as it does work to allow alpha values for drawn sprites.

While I'm here though, a huge thank your for putting this project out for others to use, it does a really good job once implemented. I also added these functions which maybe others can use :

  • disarm_get_animation_length - get the length of the spriter animation
  • disarm_get_animation_speed - get the speed of the sprite animation
  • disarm_anim_time_is - used like image_index checks but for spriter animations

For these to work just like image_index does, I've changed the project timing, where as you had animations between 0 and 1 for aTime, incremented by aSpeed of 0.01, I wanted it to correspond to the frames in the animations. So I use anim_time which is incremented per step by anim_speed, which is 1000/60 so 16.667. These three functions can then be used to do checks such as see what animation frame we are on, or if the animation has ended using the same frame numbers as Spriter shows.

Thanks again, if you need more info on these additions, let me know.

/// @desc returns the passed animations length
/// @param {struct} arm The Disarm instance to update.
/// @param {real} anim_name_or_id The name of the animation to return
function disarm_get_animation_length(_arm, _anim) {
    var entity = _arm.entities[_arm.currentEntity];
    var anim_id = entity.anims[__disarm_get_index_id_or_name(entity.animTable, _anim)];
	return anim_id.duration;
}

/// @desc returns the passed animations animation speed
/// @param {struct} arm The Disarm instance to update.
/// @param {real} anim_name_or_id The name of the animations anim_speed to return
function disarm_get_animation_speed(_arm, _anim) {
    var entity = _arm.entities[_arm.currentEntity];
    var anim_id = entity.anims[__disarm_get_index_id_or_name(entity.animTable, _anim)];
	return 	(0.01 / (anim_id.duration / 1000));
}

/// @desc returns true if anim_time is at the passed time
/// @param {real} time returns true if the anim frame is at the passed time
function disarm_anim_time_is(_time) {
	if anim_time >= _time and anim_time < _time + anim_speed return true;	
}

from disarm.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.