How do I create text at mouse when an object is clicked

Get help using Construct 2

Post » Fri May 23, 2014 12:13 am

Hey there,

I am making my first game which is a cookie clicker clone. I was using game maker studio up until tonight but think construct 2 may be a better choice for me going forward.

However I can't seem to figure this out.

What I am trying to do is when you click on the cookie object text will float from the mouse x,y position upwards for a second and disappear.

In GMS I could do this via the GML language but I do not know where to start as I see no way of adding scripted events to a Construct game though I am sure there is a way.

Hopefully someone can point me in the right direction.

EDIT

Just to give you guys an idea of what I mean. in GMS I could create an object and add a scripted event such as:

speed = 1; // set the speed of the objects movement
direction =90; // set the direction of the object. In this case 90 degrees (up)
create_text(mouse.x,mouse.y,"text here"); // create text here at mouse x and y
speed *= .9; // slows the text down every tick until it stops

Then after x ticks destroy the object.

I would then create this object on the right click event on the cookie object. thus creating the text at the mouse location.

I could do this in javascript as well pretty easily however I do not know how to "inject" javascript into the game. It all seems very drag and drop only with construct. Hopefully I am wrong though!
B
7
S
2
Posts: 32
Reputation: 541

Post » Fri May 23, 2014 1:01 am

there's a number of ways to do it. but here's one off the top of my head..

you could give the text bullet behavior and fade behavior, then make a Mouse Event-> on object clicked (your text object) enable bullet (you have to also set angle of motion to whatever direction you want the text to go..(0-360 degrees)and click 'Set Angle' to Off in the properties panel). and also enable Start Fade. and in the Properties Panel of the fade just set fade out to 1.. (and destroy after fade for a nice clean up).
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715

Post » Fri May 23, 2014 2:20 am

jobel wrote:there's a number of ways to do it. but here's one off the top of my head..

you could give the text bullet behavior and fade behavior, then make a Mouse Event-> on object clicked (your text object) enable bullet (you have to also set angle of motion to whatever direction you want the text to go..(0-360 degrees)and click 'Set Angle' to Off in the properties panel). and also enable Start Fade. and in the Properties Panel of the fade just set fade out to 1.. (and destroy after fade for a nice clean up).



Thank you. Following your advice I got it working.

For anyone who needs to know how it is done in the future this is my events:

Image
B
7
S
2
Posts: 32
Reputation: 541


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 27 guests