[SOLVED] Create New intance of same object (which is picked)

Just started using Construct 2? Post your questions here

Post » Wed Sep 24, 2014 1:41 pm

Solution: You use functions :D ...pass along the variables you want via paramaters to a function that generates the enemy and use the paramaters to set it's instant variables

G'day again guys.

Unsure if this is a "How do i" or a 'beginners question' so i chose the later because I believe if I had more experience I'd already know the answer:

I've tried a few things but it's not working right I believe it has to do with identifying the instances.

Essentially I need to completely clone the Enemy as another instance and then change at least one instance variable of the new clone. (instance variable isn't shown in the below list as I don't see it being an issue.)

Information:
Enemies are basically bouncing balls.
If they hit the ground
Triger Simulate Jump
Triger Gravity +10
Triger JumpStrength -10

I am attempting to:
When the bullet hits the (original)Enemy:
    > Create Explosion (no problems here)

    > Create Enemy(instance#2)
    > Set Enemy(instance#2) gravity and jumpstrength to that of (original)Enemy
    > Set Enemy(instance#2)scale 0.75 (no problems here)

    > Create Enemy(instance#3)
    > Set Enemy(instance#3) gravity and jumpstrength to that of (original)Enemy
    > Set Enemy(instance#2)scale 0.75 (no problems here)

    > Destroy (original)Enemy ..... (I have to do it here because I need to refernece it for the properties
    > Destroy Bullet

I'm ok with not destroying the original Enemy (but changing it's scale) but still having issues with the assigning of the properties.

Any ideas / tips / direction?

Thanks in advance :*
Last edited by humpty on Fri Sep 26, 2014 10:57 am, edited 1 time in total.
B
7
S
1
Posts: 26
Reputation: 549

Post » Wed Sep 24, 2014 2:06 pm

@humpty If you would like to post your capx you can!
B
12
S
3
G
1
Posts: 109
Reputation: 1,979

Post » Wed Sep 24, 2014 2:33 pm

Sorry Apox Inc :/
I try to write the question in a way that doesn't require someone to DL something, load it, look through etc.
I think I will start just uploading capx's though as well.

For now though I will check out functions. I believe they will be my saving grace as i can pass variables through to them it seems :)
B
7
S
1
Posts: 26
Reputation: 549

Post » Wed Sep 24, 2014 3:03 pm

@humpty No problem! It's just easier to see what you're working with when provided a capx. You can most likely work something out messing around with the variables and events a bit. Do you know anything about the global values and instance variables?
B
12
S
3
G
1
Posts: 109
Reputation: 1,979

Post » Wed Sep 24, 2014 9:39 pm

'global values' no instance variables yes.
I understand from other programming what global variables are though.
It will be nearly 1/2 the day before I get to look into the functions first. I'll start there then do a search on global values.
B
7
S
1
Posts: 26
Reputation: 549

Post » Fri Sep 26, 2014 10:55 am

Yup!
Functions were the answer. Thanks Apox Inc
B
7
S
1
Posts: 26
Reputation: 549


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests