Discuz! Board's Archiver

lostclimategame posted on 2011-9-25 03:26

node.copy()

lets say i have[code]class enemy
{

var sprite;

}
......
var enm = new enemy();
enm.sprite=scene.addsprite("angrylargewtf.png").pos(100,10);
var enm2 = enm.copy();
enm2.sprite.addaction(imoveby(100,100));
.....
[/code]// and thats not actual code, this is a "for instance" so there might be typos.

does the sprite copy and make a duplicate sprite for the second enemy or will both enemies be pointing at the same sprite?

赵韬 posted on 2011-9-27 11:43

enm.sprite.copy(),    not enm.copy()

It makes a duplicate.

lostclimategame posted on 2011-9-29 04:56

ah, so it only works with sprites :/
Page: [1]

Powered by Discuz! X1.5 Archiver   © 2001-2010 Comsenz Inc.