I have a sprite that have a few frames (animation).
The animation is on speed 0, and I can change the frames with the Right/Left arrows.
What I'm trying to do is:
When I'll click on this sprite with the middle click button, it will create a new sprite with the same position, angle, size, and.... the main problem: with the exact same frame that the sprite was BEFORE I click over.
Basically, I want to make some kind of "clone" or "duplicate" of the exact same status of the latest sprite.
Any help will be appreciated, Thanks ahead!
* Sorry about my bad English
Develop games in your browser. Powerful, performant & highly capable.
Store the original frame number in a local variable, and then after the new sprite is created, set it's frame to the stored value.
Thanks for the fast reply blackhornet,
The thing is that I start the layout clean. I have a button that create the sprites.
Each sprite created on the layout start with a random frame.
Do I need to make this 'store action' on every time I create a new sprite?
Will this eat the memory/performances if I'll create lots of sprites on the screen?
You only store the value for the time between clicking the button, and setting on the new sprite. This action won't affect performance.
I'm still trying to mess around with the all thing but I got lost, I guess it's too complicated for me because I'm still a beginner...
An example .capx file will be appreciate if anyone interested to help.
It would be simpler for you to post the file, since you have one already.
I Agree, but unfortunately I can't post links at all since I'm still a noob at the forums.
I also had the same problem with other threads...
You can use Dropbox and just munge the address a bit so the auto-detect doesn't block it.
Thanks blackhornet, I didn't know it's possible.
Here is the file, I tried to keep it clean... please notice, the frame-change (Left Right arrows) works only on the very first shape you create for some reason...
Here is the file:
Hope you or anybody else can help me solve this Clone / Duplicate issue.
Spawn doesn't work, but Create does.
First of all, Thank you for helping, I appreciate it!
It's cloning the frame + position, GREAT!
The only thing I try to understand is how to make also the angle... I'm trying to mess with it but still kind of lost.
I've edited the 'Create object" line you made, and did this:
But it's not working... well I'm still new to this all thing.
Same trick. Angle is a separate field, like Frame. Make another local variable (Can't call it Angle, so SAngle), store the clicked sprite's Angle. Set the new sprite's Angle = SAngle.
Trying to follow your instructions but I'm not sure what I'm doing wrong...
I hope that I'm on the right direction.
Don't separate them! Move the SAngle directly under Frame, and Set SAngle under Set Frame, and Sprite.Set angle under Set animation.
What you are doing is storing the data from the original Sprite. Once stored, then you create a new Sprite. All instructions after the new Sprite affect the new Sprite. As soon as you pop out to a new event line, you are back at the original Sprite.
Thanks! it works like a charm!
I have the very basic understanding of: " If this happened, than do that.. " that's how I've managed to make the very basic thing real fast.
But when it comes to the variables and expressions... I still have so much more to learn and practice, I'm far away from having a brain of a programmer but this specific experience (thanks to your help of course) was a great way to start understand how it works. I appreciate it a lot.