Tell me please. How to implement a class change scheme.
- motionGoingAnim is a class repository.
- The enemy is the object on which the classes are hung.
With this code, all classes are hung on the element, and you need to make a replacement for the next one. That is, alternately, starting from 0 to motionGoingAnim.lenght (icon1 => icon2 => icon3 => icon1 => icon2 ...) At the same time, the previous class must be removed.
icon is the character model in svg . In css set background-image . If there is any better way I would appreciate it.
var motionGoingAnim = ['icon_01','icon_02','icon_03']; if (numberAnim === motionGoingAnim.length) { numberAnim = 0; } else { enemy.addClass(motionGoingAnim[numberAnim]); numberAnim++; }
enemy.removeClass(motionGoingAnim[numberAnim-1]).addClass(motionGoingAnim[numberAnim]);- MasterAlex