Sprite gone completely when its Y value is below 0

● ARCHIVED · READ-ONLY
Started by TheoAllen 9 posts View original ↗
  1. I've been playing around with Galv Visibility Range, and I found some weird glitch on his script.

    My character jump off the screen and suddenly the visibility range gone just for a moment. At first I thought it was the glitch from the script itself, but I then I tried to reproduce the error and I succeed

    The glitch is, when you have a sprite and a tilemap which has same viewport, if the sprite the value Y has less than zero, the sprite will gone completely. I can not easily noticable since you already know that most of Sprite_Character has the oy at the bottom of the sprite.

    If you want to test, here is the test code I made

    Spoiler
    class Sprite_Test < Sprite def initialize(v) super(v) self.bitmap = Bitmap.new(450,450) bitmap.fill_rect(bitmap.rect, Color.new(0,0,0,120)) rect = Rect.new(width/2 - 100, height/2 - 100, 200, 200) bitmap.fill_rect(rect, Color.new(255,255,255,120)) self.ox = width/2 self.oy = height/2 self.x = Graphics.width/2 self.y = Graphics.height/2#~ self.zoom_x = self.zoom_y = 2.5 end def update super case Input.dir4 when 2 self.y += 5 when 4 self.x -= 5 when 6 self.x += 5 when 8 self.y -= 5 end end endDataManager.initdef updates Graphics.update Input.update @vport.update @vport2.update @spr.update @tile.updateend@vport = Viewport.new@vport2 = Viewport.new@vport.z = 50@spr = Sprite_Test.new(@vport)map = load_data(sprintf("Data/Map%03d.rvdata2", 1))@tile = Tilemap.new(@vport)@tile.map_data = map.data$data_tilesets[2].tileset_names.each_with_index do |name, i| @tile.bitmaps = Cache.tileset(name)endupdates while true 
    If you get rid the tilemap completely, the sprite will work just fine. Also if you assign a different viewport for tilemap, the sprite will have no issue as well. However, if both has same viewport, it would generate the said issue.

    Is anyone aware of this?

    To overcome this problem might simply assign a different viewport for the sprite, but it's not a neat solusion I guess. I hope the next generation of RGSS will fix the tilemap class better.

    Thought?
  2. I recall encountering something similar. I wasn't using galv's script though. I was just trying to put a sprite on the screen.  I didn't know it had to do with tilemaps. D-: thanks for sharing. I'll try it later.



    edit: Actually, I don't remember if it was the origin that couldn't go above the screen boundaries, or if it was just any part of the sprite. Anyway, it was annoying.
  3. That's not a glitch and it has nothing to do with the Tilemap class... Just make the Sprite's z bigger than the Viewport's.
  4. mmm, no. Not true. You can have a sprite with a negative z value and it will still show in the viewport. Sprite z and viewport z have nothing to do with each other.


    Does this happen if you completely disable Galv's script?
  5. ❤SCIENCE❤ said:
    That's not a glitch and it has nothing to do with the Tilemap class... Just make the Sprite's z bigger than the Viewport's.
    Hoho, so that was the problem. Welp, thank you!

    Edit :

     

    Shaz said:
    mmm, no. Not true. You can have a sprite with a negative z value and it will still show in the viewport. Sprite z and viewport z have nothing to do with each other.

    Does this happen if you completely disable Galv's script?

     
    Not tried it yet, I just try to reproduce the glitch in blank screen like what I've did in the code I made above

    I will try in Galv's visibility later. I found this glitch very long time ago.when I was working on my game

    And I ended up to limit the Y value not to go under zero. It solved my problem back then.

    Anyway, it solved I guess :D
  6. Shaz said:
    mmm, no. Not true. You can have a sprite with a negative z value and it will still show in the viewport. Sprite z and viewport z have nothing to do with each other.

    Does this happen if you completely disable Galv's script?
    You're mistaken.
  7. If it's related to the z value, why does it only happen when y goes below 0? If z does not change on either the viewport or the sprite, and that's the cause of the problem, then it should happen ALL the time, not just when y goes below 0.
  8. Simple. When two objects have the same z, acts as tiebreaker for drawing order and if the y value is the same, last created will be on top.

    Viewport: 

    z The viewport's z-coordinate. The larger the value, the closer to the player the plane will be displayed.

    If multiple objects share the same z-coordinate, the more recently created object will be displayed closest to the player.
    Sprite:

    z The sprite's z-coordinate. The larger the value, the closer to the player the sprite will be displayed.

    If two sprites have the same z-coordinates, the one with the larger y-coordinate will be displayed closer to the player, and if the y-coordinates are the same, the one that was generated later will be displayed closer to the player.
    Cheers.
  9. Just looked at Galv's visibility range... and he created the visibility range image before all the viewports. I guess, that was the problem. 

    Ok, let see .....