Moving collected coins to coin meter

candycornown

  • Posts: 43
Hello,

I am stuck with making code to move collected coins to coin meter.
Current code (attached) slides collected coin actor to coin meter, but when the player moves, that coin goes to completely different location.

I am looking for the similar effect as in the game "Lep's World".

Any suggestion how to achieve this?

Thanks!

JeffreyDriver

  • Posts: 2042
I think that the issue is happening because you're using the camera position. You need to slide the coins to the XY values of the coin meter.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

candycornown

  • Posts: 43
Thanks for reply!

I tried that too, but it moves the same. If player is not moving, the coin goes to the correct location, but if the player and camera are moving the coin will go behind or lower  (depends on camera movement).

I set X and Y attributes  to always update location of coin meter. Coin actor is now sliding to x: X, y: Y over 1 sec.


candycornown

  • Posts: 43
As I still couldn't figure it out, I decided to download couple of "Follow" behaviors from StencylForge and implement them to those actors. After changing some code to work with my game there is still the same problem. Once the camera starts moving the collected coin will go to different location (past, below, ...) the coin meter. I guess I have to constantly change the speed of collected coin in order to get it to coin meter when camera is moving?

I would really appreciate if someone has any idea how to do this.

Thanks!

Onitrent

  • Posts: 26
I think the problem is that the coin meter is anchored, but the x and y change when the camera does.  Since there's no way to trigger a slide once to a varying position, I imagine you'll need to slide multiple times to the position of the coin meter.  I would explore setting a boolean that the coin was collected, a timer to turn the boolean off, a do every .01 seconds subtracting .01 from 1,  a while updating, sliding the actor to x and y of coin meter per the new time calculated by the do every .01.

Not sure how fluid that would appear, but I imagine it's a start (hopefully an end too)
Cheers

LIBERADO

  • *
  • Posts: 2646
Remove all your previous code.
Trigger this code when a coin is collected:
   

« Last Edit: January 01, 2017, 11:25:51 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

candycornown

  • Posts: 43
Remove all your previous code.
Trigger this code when a coin is collected:
   


That worked! Thank you so much LIBERADO.

Onitrent, I tried something like this before and couldn't get it to work. Thank you anyway!

candycornown

  • Posts: 43
One more question about this.
Is there any alternative to "Anchor Coin to screen" as this moves coins to top layer and making them visible if there is pause overlay  or something similar? I tried to send it to the bottom layer but it wont work as it is anchored.

LIBERADO

  • *
  • Posts: 2646
Yes.
   
Remove all your previous code.
Create this event in your coin actor:
   
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

candycornown

  • Posts: 43
Thank you! That worked perfectly.  ;)