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 / Cannot move sprite

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Sep 2011 16:55 Edited at: 24th Sep 2011 16:56
Can anyone spot my mistake here? The idea is that as the viewport moves, the background appears stationary as it follows the viewport. However, the sprite seems to be frozen at 0,0 and won't move. I have the getSpriteX() on screen and it is definitely changing.




The value for the Sprite X value is displayed and moves as expected:



The Slayer
Forum Vice President
15
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 24th Sep 2011 18:41
Quote: "The idea is that as the viewport moves, the background appears stationary as it follows the viewport. However, the sprite seems to be frozen at 0,0 and won't move. I have the getSpriteX() on screen and it is definitely changing."

If the background remains stationary (because it follows the viewport), the values would not change, right?
And, you are adding 1 to the variable 'gBackdropX', which you are retrieving by GetSpriteX (gBackdropX)?

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Sep 2011 23:42
Quote: "If the background remains stationary (because it follows the viewport), the values would not change, right?"


If the Viewport is offset by 1, then the backdrop must be offset by 1 in order to be stationary in the eyes of the player. At least, that's the way I have interpreted the way the viewport works. I actually want it to scroll very slowly,but in order to prove the theory I'm using this 1:1 relationship.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 25th Sep 2011 01:08
I haven't used the viewport command, but I would have thought if you are moving the viewport like a camera to move around, you would want to keep the back drop at the same place. If you offset it the same as the viewport the backdrop will stay still as you are offsetting it with the viewports movement. The sprite positions will change, but as everything is being offset anyway they will appear stationary.
I think that is the problem anyway.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Sep 2011 23:31
DVader, that is exactly what I want to achieve - stationary background whilst the foreground moves with the viewport.

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 26th Sep 2011 01:33 Edited at: 26th Sep 2011 01:34
If you truly want your background stationary, can't you just lock it to the screen? Or am I missing the point?

And even after you lock it to the screen, you can still move it. At least I think that's the case. Hmmm... maybe just scrolling the U part of the sprite U/V?

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 26th Sep 2011 03:16
Are you sure that gBackdropSprite holds the correct handle?
This quick test works for me:


The backdrop sprite stays stationary while the foreground sprite slowly slides out of the moving viewport.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Sep 2011 00:57
Fixed with the new update.

LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 9th Oct 2011 03:22
Happy to help Any more issues, remember we are always listening here: http://code.google.com/p/agk/issues/list

I drink tea, and in my spare time I write software.

Login to post a reply

Server time is: 2024-11-22 03:32:07
Your offset time is: 2024-11-22 03:32:07