开发者

How to combine image and vector animation in Raphael

I'm trying to animate some stuff with R. So i got a PNG which i can animate, but i want to put a circle around the PNG and animate the two as one.

I know one can do it with a set like:

this.ship = paper.set();
this.ship.push(
    paper.circle(116, 116, 20).attr("fill", "#ff0"),
    paper.image("assets/img/ship.png", 100, 100, 32, 32)
);

and then:

{
this.ship[i].animate ...
}

...but thats anoying cause of the differences in the attribs of the both elements.

Does someone has a hint what would be a go开发者_如何学运维od way to start with? Thanks!


In my understanding a paper.set is able to handle animations like

this.ship.animate(...)

otherwise you shouldn't use paper.set in this case. i suggest to use animateWith

see: http://raphaeljs.com/reference.html#animateWith

var img = paper.image(...);
var circle = paper.circle(...);

img.animate({...}, 2000);
circle.animateWith(img, {...}, 2000);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜