Precise Movement [SOLVED]

Get help using Construct 2

Post » Mon Mar 04, 2013 8:58 am

Online demo
capx file
I want to move my sprites to an exact position. In the example project sprites are at 100 pixels in X coordinates. And i want to move them 400 pixels further. So after click, sprites will reach to 500 pixel area. I tried different techniques But none of them works good. Could you help me?mrcgkh2013-03-04 14:43:54
B
20
S
8
G
6
Posts: 176
Reputation: 8,047

Post » Mon Mar 04, 2013 10:32 am

I have done something like this:

give your sprites a couple of instant variables (I used ivMyPosX and ivMovingToX)

when you want sprite to move make ivMovingToX = ivMyPosX+400

start movement (ie bullet)

every 0.1 seconds
if sprite position.x >= ivMovingToX
    stop bullet motion
    set sprite.x = iVMovingToX (just incase it is slightly over)

if you need to move again then just add 400 to ivMovingToX and start the bullet again.

RamPackWobble2013-03-04 10:34:16
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
59
S
30
G
34
Posts: 1,194
Reputation: 23,767

Post » Mon Mar 04, 2013 10:35 am

Using move to - plugin might be what you are looking for. EaseTween is another alternative. You can achieve same behaviour with default actions too, but using the plugins is much cleaner.

http://www.scirra.com/forum/behavior-moveto_topic44845.html
http://www.scirra.com/forum/behavior-easetween_topic53288.html

EDIT: Your wait action problem is due the fact that loops execute in one tick. So what happens is all the stages f the loop run instantly. You could use 'wait X*loopindex' action.vee412013-03-04 10:38:55
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon Mar 04, 2013 10:45 am

here is your capx edited to show one way - I altered the distance to 50 . you can also click on sprite while it is moving to increase distance in jumps of 50

https://dl.dropbox.com/u/143636437/temp/PreciseMovementProblemedit.capx
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
59
S
30
G
34
Posts: 1,194
Reputation: 23,767

Post » Mon Mar 04, 2013 2:41 pm

Oh thank you. You are life savers. I will implement the technique in this game
B
20
S
8
G
6
Posts: 176
Reputation: 8,047


Return to How do I....?

Who is online

Users browsing this forum: ETgirl79, Matthew de, semaso and 23 guests