How do I 'flash' any sprite in a direct line to my cursor

Get help using Construct 2

Post » Thu Apr 17, 2014 12:20 pm

I have a simple board game, when I click a location on my board the area turns green.

Image

The board is created by placing 10*10 of 40x40px targets on the board for each reference (e.g. A 1, or C 5, etc).

What I would actually like to achieve is to have each target from top reference point and from left reference point to flash in towards the clicked target, like in the image below;

Image

Any ideas on how to achieve this? Each letter along top or number down left side is an instance of a Sprite font... maybe some line of sight? I just can't think of how to do it.
B
5
S
1
Posts: 34
Reputation: 364

Post » Thu Apr 17, 2014 2:27 pm

i was going to actually do it, but then i realized it was going to take me too long xD
however, here's what i was going to do:

When you click a valid target, call a function and store it's X and Y in the function parameters.
Then create 2 new squares, and set one on X,1 and another on Y,A. (each sharing only the X or the Y of the the target you clicked, but on the edge of the board)
And then move them 1 square distance every X seconds for as long as their corresponding X or Y is less than the "function parameter stored" X and Y of the target.
Then probably destroy the 2 squares as they where there just for showing off :D.

Hope you understood me ^^, feel free to ask any follow up questions :D
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Thu Apr 17, 2014 8:09 pm

Thanks @Sargas, I'm prone to over think solutions - this seems like a simpler way to achieve my outcome. I'll give it a go and report back on the outcome.
B
5
S
1
Posts: 34
Reputation: 364

Post » Thu Apr 17, 2014 9:54 pm

Updated
-----
I've sorted it out - I moved the "Every" sub-event out as it's own event (no need for while) and it works. I don't know why it didn't work when it was a sub-event of the touch event.

Thanks for your help @Sargas
-----

@Sargas, I'm having some trouble;
- I created 2 clones of my target, one called SeekerX and the other SeekerY
- On touching a target I create an object;
- SeekerY (Target.X, starting y position)
- SeekerX (starting x position, Target.X)

This looks good so far, but now I have to move them to create the animation effect.

So I add a sub event;
- Every 2.0 seconds: SeekerX | Set X to SeekerX.X + 40

When I run the game, the SeekerX object moves one block across, but no further...

So I try a while loop;
- While SeekerX.X < Target.X { SeekerX | Set X to SeekerX.X + 40 }

The seekerX object instantly moves to the Target.X position.... too fast, need to slow it down

So I combine the while loop with the delay (while SeekerX.X < Target.X { Every 2.0 seconds {SeekerX | Set X to SeekerX.X + 40) }} when I click a target nothing appears any the tab becomes unresponsive... I guess there is something wrong with my loop, but logically it seems to make sense.

thoughts?
B
5
S
1
Posts: 34
Reputation: 364

Post » Fri Apr 18, 2014 2:11 am

@jwoods so... does it work?
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Fri Apr 18, 2014 4:01 am

Yep, it sure does @Sargas

I cloned Target sprite object (SeekerX and SeekerY) and added a sub which executes every 5 seconds.

Image

thanks again.
B
5
S
1
Posts: 34
Reputation: 364

Post » Fri Apr 18, 2014 9:01 am

hey, that's pretty much what i had in mind ^^!!

are you making a battleship game? can i play when you're finished? :D!!! i love battleship ^^! i spent hours as a child playing this on paper... once, with a cousin, we made a 100x100 board and played for months sending moves over e-mail. eventually we realized we both had made wrong annotations, since all the input was made by hand, and had to give up on it... that was like 2 months in xD
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Fri Apr 18, 2014 10:14 am

@Sargas I sure am, and yes, will let you know when/if I finish. Mine has a little spin, it's a replica of Battle Cruiser from Space quest 5....

I haven't gotten far yet (placing 2 ship types randomly on the board, but you can check out progress here
B
5
S
1
Posts: 34
Reputation: 364

Post » Fri Apr 18, 2014 10:22 am

It's looking good :D are you going to make it a multiplayer on-line game?

Let me know if you need any more help with this ^^
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Fri Apr 18, 2014 10:55 am

first release will simply be turn based, against AI (Constructs Random system expression), but depending on time, motivation and interest I might explore taking it further

no doubt I'll need loads of help - thanks again @Sargas.
B
5
S
1
Posts: 34
Reputation: 364

Next

Return to How do I....?

Who is online

Users browsing this forum: jasontoups, OddConfection, Yahoo [Bot] and 3 guests