Spawn another object

Get help using Construct 2

Post » Wed Jan 25, 2012 12:46 pm

Hello.

I have to sprites with bullet behaivor, which moving to each other.
(sprite1) ->
                                    <-(sprite2)
When sprite1.x equal to sprite2.x i must spawn sprite3.
But have no new object. Can you tell me why? Bug?

http://dl.dropbox.com/u/58705288/test.capx

Thnx in advance.etspring2012-01-25 12:47:15
B
6
G
1
Posts: 14
Reputation: 1,353

Post » Wed Jan 25, 2012 2:17 pm

Equal is a little bit risky to use.
Perhaps this capx is will help you?

CAPXTastyBytes2012-01-25 14:19:07
B
14
S
2
G
6
Posts: 110
Reputation: 3,839

Post » Wed Jan 25, 2012 2:29 pm

Thanks TastyBytes.
But, question still actual.

Just imagine:
Sprite1 is a bomber and Sprite2 is a vechile and Sprite3 is a bomb.Destroying of these objects is not correct when condition Sprite1.X < Sprite2.X

I see only one way to make it correct with "Sprite1.X < Sprite2.X" - we must insert instant variable "Bomb_count = 1" to bomber. But this way is so bulky.

Any ideas?
B
6
G
1
Posts: 14
Reputation: 1,353

Post » Wed Jan 25, 2012 2:39 pm

Well i spent some time trying to figure out how to fix it and couldn't come up with any good ways to use the "Compare X" that you used. An alternative if you can't figure out the "Compare X" is "if Sprite is overlapping Sprite2". But then you will have to have them collide of course.
B
22
S
3
G
6
Posts: 52
Reputation: 4,387

Post » Wed Jan 25, 2012 3:00 pm

omgitburns thanks
Your way have another problem.
Gamezone is 400x400, Sprite1 moving on y=100 and Sprite2 moving on y=300, size of both sprites is 30x30 and they never collide ;(
We can make sprites with size 30x400, but it`ll be perversion ;)))))))


B
6
G
1
Posts: 14
Reputation: 1,353

Post » Wed Jan 25, 2012 4:17 pm

A capx

Tastybytes is right about the fact that "the same X for both sprites" is likely to not happen at all.

Check for an "area".
In the capx I make sure both sprites are in 10 pixels range of each other, this seems to do the trick when they "cross".
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,786

Post » Wed Jan 25, 2012 4:44 pm

Objects don't move smoothly, they actually move in little jumps every frame. Also, one object can be at X = 100, and another can be at X = 100.000000001, and those are not equal, so the chances the event is true is almost impossible.

You probably want an event something like

+ Sprite2.X < Sprite1.X ("sprite2 is to left of sprite1")
+ Trigger once ("only do this once")
-> Spawn sprite3
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Wed Jan 25, 2012 5:04 pm

Thanks to All.

Ashley, i did this thing:
Every tick i compared to variables floor(Sprite1.X) and floor(Sprite2.X) - have no result or "floor" did not work here too?
B
6
G
1
Posts: 14
Reputation: 1,353

Post » Wed Jan 25, 2012 5:06 pm

It will make integers out of your coordinates, so it works.
But with two objects moving at fixed interval of distance (each tick they move by X pixels), starting on "random" position, what are the odds that both objects ends up exactly at the VERY SAME X during their course ?

Answer: close to none.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,786


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, anty21ro and 17 guests