Reference to object type

0 favourites
  • 10 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hello, im trying to make tower defense game.

    Right now when my tower shoot - it shoot projectile that i manualy put into event. Problem is - if i want to have 50 or even more tower i need to create alot of same type events, so every tower type spawn its own projectile.

    I want to make instance var in towers, wich will hold projectile type, and use this var in event. Is there any way to do that?

  • Families, bro.

    Check out the manual page on them, it will explain better than me

    but in short:

    If you create the family 'tower', and give it some variables, all the objects you put into 'tower' will inherit that family's variables.

    You can then refer to the family 'tower' in the events sheet like it was any other object.

  • As soon as you give it an instance variable, can't you simply add a check to determine shot type ?

    instance variable towertype="missle"

    and compare instance variable   

    towertype="missle", action shoot missles

    towertype="bullet", action shoot bullets

    that sort of thing

  • Still each of your tower has to be manualy binded to event, i was looking for solution to make one event-action for all towers in general.

  • It will always be necessary to tell the computer what you want to do with what object under which conditions. picking/referencing the object will be necessary.

    You could use function with parameters if you only want one event.

    One of the parameters could be the missile type.

  • Ok, lets take another aproach.

    I want to create a behavior that will spawn object, and type of object should be selected by string, rather then object picker.

    I looked at sprit plugin, and found a spawn function that do 'Spawn another object' action. It leads to function in preview.js. It pass object type within a javascript object, so i need first to get this object type.

    My guess is to find array that contain all object types and search required type by name (string) and then use default function to spawn new object.

    Shouldnt be too hard, but i cant figure out where is object type array, so i could access them in plugin script. Also - object type name is uniqe per type? Becuase if not, i guess whole idea is dead.

    May be some one know where is this array? Tnx for answers btw!

  • function is what you need here

    TType= missle   --> call missle

    TType= bullet   --> call bullet

  • I understand your solution. But if i have alot of towers its become problem. Also i have similar trigger to build tower, and there can be more mechanic wich will be hard to maintain and change.

    Ok, i cant post URL to a pic >.< but ive got your idea - i need different solution.

  • I don't recommend using third party plugins that often, but maybe you should look into the nickname plugin, you can find it in the plugin section of the forum.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sir, you saved my day!

    Its looks like exacly what i need.

    My thanks!

    After i test it - absolutly awesome. Exacly what i need. Thanks again!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)