As the title says is there a way to have an element on the stage be it
an image,
shape
or a symbol
and duplicate it using javascript and have it controlable
so for example have an enemies symbol with animation and duplicate it with code each time you need to spawn an enemy and still have the duplicate have a timeline which is a replica of the first one so you an go enemy1.contineTimeline
enemy2.cotinueTimeline
I think the first option with images and shapes will be easier , but symbols may be difficult. Could this be done? If any of this could be done please let me know thanks!
sure you can clone or duplicate elements but it’ll be out of hypes internal bookkeeping. so no for complex structures or previously recorded animation.
So no symbols can be duplicated with code? This was my concern, maybe in the future this would be allowed. If it could things like dynamically generated elements and games would work great!
You can duplicate anything but You will probably mess up hypes Control on it
I’m discussing via code here though, how could you duplicate a symbol via code
easiest approach: set an id to the symbol then use jqueries [clone][1]
$("#yourIdHere").clone().appendTo($("#" + hypeDocument.documentId()));
and you’ll have a problem
A little test with a rotating square symbol.
JqueryDuplicate.hype.zip (51.0 KB)
sry for my last post … it’s always a bad idea to mess up with hypes documentstructure.
instead think of how ot achieve sthg. simular with its strengths.
for example you can place multiple instances of a symbol on a scene. place them offscreen, hidden whatever …
give each a own unique id, set a class, set relative timelines for each and your good of some gaming structure as you can access each, or all, or a few … and let them react …
Well if there’s anything i really like is pushing and breaking hype’s limits to create things. With your example it’s good but say i want to generate rain i would need to make 100 rain elements and then code them versus making one and duplicating it with code which would be less work and the stage wouldn’t be overfilled with symbols. Just as an example of course, but yeah . And thanks for the code snippet! And thanks Lomax for the example!