How do I fuse two objects of the same type? <SOLVED>

Get help using Construct 2

Post » Mon Jul 27, 2015 1:39 pm

I´ve got one sprite; its size, speed and hp is measured through its animation frame directly, so don´t worry about any of that. I want to make it so when this sprite overlaps other of its kind, both get compared to each other and the one with the biggest or equal animation sprite gets added the number of the other´s animation frame (if the biggest´s animation frame is smaller than 8, if its animation frame is 8 nothing will happen). In the end the smallest of the two will be deleted.

Examples:
·Sprite (frame=0) + Sprite (frame=0) = Sprite (frame=1)
·Sprite (frame=1) + Sprite (frame=2) = Sprite (frame=3) etc...

I know it sounds simple, and I think it is, but I´ve been thinking for a while, and even though code I made kind of works I know it´s not the correct way of approaching it...

Any help would be greatly appreciated.
Image
Last edited by CloveltOc on Mon Jul 27, 2015 2:36 pm, edited 1 time in total.
B
9
S
3
Posts: 153
Reputation: 1,272

Post » Mon Jul 27, 2015 1:47 pm

This is one of those cases you use "system pick nth instance"
From the top of my head it would be something like this:

I'd add a global variable Exchange

enemy is overlapping enemy
> system set Exchange to 0
-- system pick nth instance = 1
-- system trigger once
> system set Exchange to enemy.animationframe
> enemy destroy
-- system pick nth instance = 0
-- system trigger once
> system add enemy.animationframe to Exchange
> system set enemy.animationfram to Exchange
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jul 27, 2015 1:55 pm

Ah forgot adding an extra event/condition to set Exchange back to 8 if it's higher than that..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jul 27, 2015 1:57 pm

Nope, now it doesn´t work at all :I
Image
Image
B
9
S
3
Posts: 153
Reputation: 1,272

Post » Mon Jul 27, 2015 2:09 pm

You could change the is overlapping with on collision and remove the trigger once..

This example works, just drag and drop the sprites:
https://dl.dropboxusercontent.com/u/485 ... rames.capx
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jul 27, 2015 2:16 pm

Could it be that in your example the initial animationframe is 0, while for this to work properly it should be 1?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jul 27, 2015 2:30 pm

EDIT: Absolute facepalm, the initial frame was set to 0, I was setting the initial frame of a sprite with same appearance, I deeply apologise

Thanks for everything, man, it now works sorry for being dumb :)
B
9
S
3
Posts: 153
Reputation: 1,272


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests