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.

2D All the way! / Help with a 2d side-scroller :-)

Author
Message
Digital Dragon
20
Years of Service
User Offline
Joined: 17th Dec 2004
Location: ...
Posted: 1st Apr 2005 08:22
I have taken a couple of snippets from this forum and now i have a base to work on but the problem is i can't move my character down so it is level with the terrain.
this is the code


D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 5th Apr 2005 07:02 Edited at: 5th Apr 2005 07:20
You need to put your sprite positioning variables (X and Y) before your SPRITE SpriteNumber,Xpos,Ypos,ImageNumber command. You need to define your variables first before you try to position your sprite. You don't need to use real numbers (X# and Y#) for the SPRITE cammand, use integers.

If your X and Y variables are both zero, your sprite will be in the upper left-hand corner. If you want your sprite to be centered with your background you will have to subtract your sprite image size from your screen size and divide by two.

x = (bitmap width() - sprite width(SpriteNumber)) / 2

Example:
256 = ( 640 - 128 ) / 2

y= (bitmap heigth() - sprite height(SpriteNumber)) / 2

Example:
112 = ( 480 - 256 ) / 2

If your background picture has a floor, you will have to adjust your Y variable accordingly.

y = bitmap height() - sprite height(SpriteNumber)

Example:
224 = 480 - 256

Let me know if this helps.

Login to post a reply

Server time is: 2025-05-17 15:59:23
Your offset time is: 2025-05-17 15:59:23