issues
search
replit
/
kaboom
💥 JavaScript game library
https://kaboomjs.com
MIT License
2.66k
stars
226
forks
source link
'pingpong' does not work when 'loop=false' & playing anim do some thing when keyframe
#778
Closed
tangbobo
closed
10 months ago
tangbobo
commented
11 months ago
Discussed in
https://github.com/replit/kaboom/discussions/777
Originally posted by **tangbobo** October 29, 2023
``` const _ = kaboom({ global: false, debug: true }) // _.debug.inspect = true _.loadSprite('hero', '/sprite-sheet-161x106.png', { sliceX: 6, sliceY: 6, anims: { 'idle': { from: 0, to: 5, speed: 12, loop: true }, // 'pingpong' does not work when 'loop=false' 'attack': { from: 6, to: 12, speed: 16, loop: false, pingpong: true }, 'skill': { from: 13, to: 30, speed: 16, loop: false }, 'hit': { from: 31, to: 35, speed: 16, loop: false } } }) function Sprite(x, y, t) { return _.add([ _.sprite(t, { anim:'idle' }), _.pos(x, y), _.area({}), _.anchor('center') ]) } function Character(x, y) { const sprite = Sprite(x, y, 'hero') sprite.onAnimEnd(() => { sprite.play('idle') }) sprite.SKill = (target) => { sprite.play('skill',{ // I want to add this callback onFrameChange:()=>{ } }) //I need to know when to keyframe target.play('hit') _.addKaboom(target.pos, { scale: 1.2, speed: 1 }) } sprite.Attack = (target) => { sprite.play('attack') target.play('hit') _.addKaboom(target.pos, { scale: 0.5, speed: 1.5 }) } return sprite } const enmy = Character(200, 400, 'hero') enmy.flipX = true const maga = Character(400, 400, 'hero') _.onMousePress(() => { if (Math.random() < 0.5) { maga.Attack(enmy) } else { maga.SKill(enmy) } }) ``` # my code ## 1: 'pingpong' does not work when 'loop=false' ## 2: I need to know when to keyframe
slmjkdbtl
commented
10 months ago
Fixed in 543c373, will publish soon
Discussed in https://github.com/replit/kaboom/discussions/777