GMS 2 What am I doing wrong ?

Discussion in 'Programming' started by Bilbo, Feb 17, 2017.

  1. Bilbo

    Bilbo Guest

    Hello guys,
    so basically im using this code:
    if (keyboard_check(vk_right))

    x = x + 4;

    if (keyboard_check(vk_left))

    x = x - 4;
    but my problem is, that when I move the object it draws itself there. I basically have my sprite all over my room. Could anyone help ?
    Thanks in advance
     
  2. PhenomenalDev

    PhenomenalDev Member

    Joined:
    Jan 5, 2017
    Posts:
    121
    What's the complaint with it drawing? It's meant to. Btw your codes a bit unoptimised it should be:

    if (keyboard_check(vk_right))
    {x += 4}

    if (keyboard_check(vk_left))
    {x -= 4}
     
  3. dphsw

    dphsw Member

    Joined:
    Oct 19, 2016
    Posts:
    82
    Do you mean you're ending up with lots of copies of your sprite drawn all over the room?

    If so, then the problem is somewhere else other than this code. The first thing I'd suggest is to make sure that 'Clear Display Buffer' is ticked in your room settings.
     
  4. Bilbo

    Bilbo Guest

    But what can I do if I dont want it to draw ?
     
  5. Xer0botXer0

    Xer0botXer0 Member

    Joined:
    Jun 29, 2016
    Posts:
    670
    Disable the objects sprite, enable it's mask if required.
    Draw the sprite using the draw event at specified location therefore even if your object moves your sprite will remain in it's position, according to what you want.

    If that's not right, then you need to be more clear on what you're looking for, perhaps an explanation of what you're trying to achieve.
     
  6. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,959
    Maybe it is not the same in GMS2, but in 1.4 a sprite trail would form if you didn't give a room a background image and turned off background color drawing.
     
    rIKmAN likes this.
  7. Bilbo

    Bilbo Guest

    Im trying to move an object left and right but it " copys " itself on its position
     

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