User Tag List

Results 1 to 3 of 3

Thread: help with 2d sprite scaling

  1. #1
    Clicker Fusion 2.5

    Join Date
    Apr 2007
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with 2d sprite scaling

    How do i make a caracter scale acording to how far he is from the camera, ive tryed to do this before i cant figure it out how to do it, what i want to do is when i move the caracter up the screen it will be smaller and forvards against the camera it will get bigger, like in resident evil, or old adventuregames. I would be extreamly thankful if someone could show me.
    Attached files Attached files

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: help with 2d sprite scaling

    You need to have a couple of constant variables for each frame YMax (the Y position of your character when he's at his closest possible position to the camera (usually at the bottom of the screen), YMin (Y position at the furthest position away from the camera (perhaps the middle of the screen so that we can paint a horizon into the top half?)

    So

    YMax = 480 (bottom of a 640x480 frame)
    YMin = 240 (Mid way to bottom of the frame)

    therefore we have 240 pixels of range that we want to play with:

    Always
    - Set Character scale to 1.0 + (Y Position of Character - YMin)/(YMax - YMin)

    Therefore, you'll have the character twice the size at the bottom of the screen, and the original size at the horizon. Twice the size may be too big, so you could reduce the max scale factor to half:

    1.0 + ((Y Position of Character - YMin)/(YMax - YMin)/2.0)

    That way maximum size is 1.5, and minimum is 1.0

    or you could use half and 1.5:

    0.5 + (Y Position of Character - YMin)/(YMax - YMin)

    You should get the idea. The reason I'm adding the .0 at the end is so that it uses decimals rather than whole numbers, otherwise it won't scale properly. I had to add a few more 1.0* to the file attached to enforce this. You should know that times-ing a number by 1.0 gives you the same number.

    If you want the character climb up and down stairs, well you'd have to set triggers to scale him at these locations, eg. special zones that act differently to the constant scaling as shown in this solution.



    Edit: I forgot to take into account that your example uses a height of 408, substitute 480 for 408 for a more accurate result in your game
    Attached files Attached files

  3. #3
    Clicker Fusion 2.5

    Join Date
    Apr 2007
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: help with 2d sprite scaling

    Thank you very much,ive been trying too do this for a loong time and now i understand how it works. this forum is the best =)

Similar Threads

  1. scaling
    By Skyhunter in forum SWF/Flash Export Module Version 2.0
    Replies: 9
    Last Post: 20th March 2013, 07:31 AM
  2. Scaling?
    By KLiK-iT in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 21st June 2012, 08:20 PM
  3. Scaling app down
    By Keith in forum SWF/Flash Export Module Version 2.0
    Replies: 8
    Last Post: 25th February 2012, 06:40 PM
  4. Scaling
    By TreeHugger in forum File Archive
    Replies: 3
    Last Post: 10th April 2008, 05:08 PM
  5. Scaling
    By Raphael in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 14th September 2006, 08:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •