How to shift sprites?

Discussion in 'Programming' started by Maximilian Levine, Jun 26, 2019.

  1. Maximilian Levine

    Maximilian Levine Member

    Joined:
    Jun 20, 2019
    Posts:
    18
    I am trying to make a scrolling background and need a function that can shift the sprite.
    For example, here would be the sprite before being shifted:
    [​IMG]
    Then after being "shifted" left a few times:
    [​IMG]
    So it loops back over
     
  2. pipebkOT

    pipebkOT Member

    Joined:
    Dec 13, 2018
    Posts:
    210
    @Maximilian Levine

    shift? like, change the sprite? if is that, you can change the sprite with

    Code:
    sprite_index= name of the sprite


    if you want to mirror a sprite (flipping it) you can use

    Code:
    image_xscale=-1

    if you want to rotate a sprite you can use

    Code:
    image_angle=the angle that you want (in numbers from 0 to 360)
     
  3. Bayesian

    Bayesian Member

    Joined:
    Sep 13, 2016
    Posts:
    423
    You'll want to use draw_sprite_part. For the math you need to know the starting off set, the difference between the starting offset and the current offset which should be floored and finally you need to mod the difference by your sprite width so that it wraps around.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice