Discuz! Board

 

 

Search
Discuz! Board Forum Integration Questions node.copy()
View: 518|Reply: 2
go

node.copy()

Rank: 2

Post on 2011-9-25 03:26 |All posts
lets say i have
  1. class enemy
  2. {

  3. var sprite;

  4. }
  5. ......
  6. var enm = new enemy();
  7. enm.sprite=scene.addsprite("angrylargewtf.png").pos(100,10);
  8. var enm2 = enm.copy();
  9. enm2.sprite.addaction(imoveby(100,100));
  10. .....
Copy
// 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?

Rank: 4

Post on 2011-9-27 11:43 |All posts
enm.sprite.copy(),    not enm.copy()

It makes a duplicate.

Rank: 2

Post on 2011-9-29 04:56 |All posts
ah, so it only works with sprites :/
Security Q&A Change Security code Change

Archiver|Comsenz Inc.

All time is GMT+8, 2013-5-20 20:30 , Processed in 0.032042 second(s), 13 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.