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

0 favourites
  • 13 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • I have a simple board game, when I click a location on my board the area turns green.

    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;

    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.

  • 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 .

    Hope you understood me ^^, feel free to ask any follow up questions

  • 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.

  • 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?

  • jwoods so... does it work?

  • Yep, it sure does Sargas

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

    thanks again.

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

    are you making a battleship game? can i play when you're finished? !!! 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

  • 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

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

    Let me know if you need any more help with this ^^

  • 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

  • off-topic (slightly). When I click a target it instantly shows if it was a hot or miss - how would i delay showing the target result until the two "seeker" targets disappear?

  • I would use variables.

    when you click the 1st time, the variable=0; the 2 squares come at the center. when they arrive, set variable to 1.

    and when variable=1, show result.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi Jwoods. I know this is a pretty old post, and you may not get this, but I wanted to ask you a few questions about what you have started. I have a similar game concept in mind and would love to pick your brain on this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)