Closed Elyx0 closed 12 years ago
(And neglect the offsets settings)
Found a workaround.
// update the background:
if(gameQuery.animation.type & $.gameQuery.ANIMATION_VERTICAL){
if(gameQuery.multi){
$(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.multi)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.delta*gameQuery.currentFrame)+"px");
} else {
$(this).css("background-image","url('"+gameQuery.animation.imageURL+"')");
$(this).css("background-position",""+(-gameQuery.animation.offsetx)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.delta*gameQuery.currentFrame)+"px");
}
} else if(gameQuery.animation.type & $.gameQuery.ANIMATION_HORIZONTAL) {
if(gameQuery.multi){
$(this).css("background-image","url('"+gameQuery.animation.imageURL+"')");
$(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*gameQuery.currentFrame)+"px "+(-gameQuery.animation.offsety-gameQuery.multi)+"px");
} else {
$(this).css("background-image","url('"+gameQuery.animation.imageURL+"')");
$(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*gameQuery.currentFrame)+"px "+(-gameQuery.animation.offsety)+"px");
}
}
Tested this and it appears to work. Have added to my fork and issued a pull request.
This appears to have been because I had default CSS background images (handy and more efficient in some cases) and was assigning animations with a blank 'imageURL' property. This assigns the inline style background-image:url(''); which breaks everything after it. Even though clearly an error it's actually hard to debug because the above doesn't show in webkit web inspector on the element. Possibly could be the same error Elyx0 is experiencing.
Added minor alterations to code which only assign background-image if imageURL is present. Prevents similar errors and add versatility of assigning background-image via a css class if needed and overriding on a per animation basis. Pull request sent.
Ok then I will close the issue since I've merged you code. If Elyx0 is still following this issue and that the solution doesn't solve his problem he is welcomed to re-open it!
setAnimation does not change the background-image anymore. (But works fine on the stable Version 0.5.1.