Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Sprite Movement To Mouse on Release

Author
Message
TheViking
12
Years of Service
User Offline
Joined: 16th Feb 2012
Location:
Posted: 6th Jun 2014 01:51 Edited at: 6th Jun 2014 06:29
Hey All,

Just been getting stuck on some sprite movement issues.

I had either two options of how I would do sprite movement:
1) click on the sprite and drag, creating a path to follow, when released the sprite moves in that direction.

OR

2) Simply click and release then the sprite moves to that location.

I have tried many things but none seem to work well. The click and drag using mouse joints is nice, however I don't want sprite rotation, (which can still be done easily) but also don't want gravity applied.

Essentially, I'm working at a point and click adventure. (OLD SCHOOL STYLE)

I'll have to figure out pathfinding eventually, but for now, just moving the sprite on angles not just left/right would be great! any suggestions on how?

Thanks!

EDIT:

Ok, I got a kind of crappy movement going. I know the code is not very logical, however it's a start. However, now I'm kind of stumped on how to get the coordinates working right. The sprite moves to where the mouse is, but, the background scrolls too, which pushes it beyond the end point. I know its a simple fix, but can't see it. Here's the code:



Any hints on making this smoother/more accurate would be appreciated.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Jun 2014 11:11
i use this for movement with a help of simple target sprite.

maybe u can disable SetPhysicsGravity ( 0, 0 )
disable rotate SetSpritePhysicsCanRotate ( iSpriteIndex, 0)



AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
TheViking
12
Years of Service
User Offline
Joined: 16th Feb 2012
Location:
Posted: 7th Jun 2014 20:01
Ok, I kind of have what I was looking for now. Just needed some tweaking. Thanks Markus, the Rotate and gravity seems to work great. Had to couple it with Turning on/off physics on the object once it got to where it needed, or it would just continuously follow the pointer after. But none the less, still lots to do on it, but I got the main issue resolved.



Seems much shorter and simpler now. Thanks again.

Login to post a reply

Server time is: 2024-11-25 05:50:34
Your offset time is: 2024-11-25 05:50:34