How do I spawn object on keypress at same time as other act.

Get help using Construct 2

Post » Wed Jan 07, 2015 9:19 pm

Hi, all.

I have a problem with this seemingly simple action:
Untitled.png


One could assume that at the moment of a keypress an object would be created at the coordinates given - either where the object was or where it ends up being. What we get is this:
Problem.gif


For some reason nothing happens on the first keypress and the following ones always lag behind.

Question: How do I spawn an object on any key pressed OVER the base object and when the key is pressed and not a whole step later?
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Wed Jan 07, 2015 10:17 pm

Make it like this:
Image
ImageImage
B
115
S
51
G
24
Posts: 790
Reputation: 23,505

Post » Wed Jan 07, 2015 10:45 pm

Hi,
I think it looks good they way you have it, that the trace is created where the Sprite was when you pressed the button. If you really want it to be created in the new spot a simple way would be to add a wait with 0.05s before the trace is created.

I'll attach an example.
You do not have the required permissions to view the files attached to this post.
B
39
S
9
G
4
Posts: 163
Reputation: 6,521

Post » Thu Jan 08, 2015 8:09 am

@OneMuppet - that's the ticket! The need to shift the creation action by a tick - I did it in a slightly different way (setting a variable that's checked - so this happens on next tick) and now it works.

alextro's solution would also work I guess, but I have MANY keyboard functions so adding the drawing subroutine to each one would be a bit messy.

About the look - this was a very rough demo capx of the idea, in reality it looks like this:
Image

Thank you both for your time.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Thu Jan 08, 2015 11:47 am

could do like so
You do not have the required permissions to view the files attached to this post.
B
257
S
43
G
15
Posts: 1,992
Reputation: 41,535

Post » Thu Jan 08, 2015 11:55 am

Thanks, @Lordshiva1948, but it already works decently, as the gif above shows. Without the extra overhead of a pin behaviour.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Thu Jan 08, 2015 1:36 pm

Looks cool what is it? A vehicle builder/configurator?
B
39
S
9
G
4
Posts: 163
Reputation: 6,521

Post » Thu Jan 08, 2015 1:39 pm

It's a StuffGEN - look here: stuffgen-an-object-editor-made-with-c2_t122002 to see a slightly earlier version.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146



Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests