Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Index of dynamically created object  (Read 3471 times)

0 Members and 1 Guest are viewing this topic.

Krosad

  • Anate Studio
  • Occasional poster
  • **
  • Karma: 2
  • Offline Offline
  • Gender: Male
  • Posts: 97
  • anatestudio.com
    • View Profile
    • Anate Studio Web site
Index of dynamically created object
« on: November 25, 2012, 11:02:13 PM »

Hi,

here the problem.

i have dynamically created objects

for (var a=1; a<=70; a=a+1)
{
var module = Scene.CreateEntity("module" + a);
}


Then i need to change a sprite of a certain object and need of code like this

module[c].SetSprite("scenes\stcomp\module1.png");

this is wrong. How will be correct?
Logged

s.belov

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 38
    • View Profile
Re: Index of dynamically created object
« Reply #1 on: November 26, 2012, 05:46:46 AM »

var Ent;
global module;

for (var a=1; a<=70; a=a+1)
{
   Ent = Scene.CreateEntity("module" + a);
   module[a] = Ent;

}

...

for (var c=1; c<=70; c=c+1)
{
   Ent = module[c];
   Ent.SetSprite("scenes\stcomp\module1.png");
   module[c] = Ent;
}
Logged

Krosad

  • Anate Studio
  • Occasional poster
  • **
  • Karma: 2
  • Offline Offline
  • Gender: Male
  • Posts: 97
  • anatestudio.com
    • View Profile
    • Anate Studio Web site
Re: Index of dynamically created object
« Reply #2 on: November 26, 2012, 12:29:38 PM »

thanx!
One more question

I added a script to each entity of the array.
What should i write in this script to return entity index in array on leftclick?
Logged
 

Page created in 0.028 seconds with 18 queries.