Fixes wearable sprite offset and layering issues when autoscrolling the map

This commit is contained in:
infinitefusion
2024-07-05 17:52:17 -04:00
parent 6180590860
commit 4a6a889b3e
15 changed files with 10 additions and 19 deletions

View File

@@ -2,7 +2,6 @@ class Sprite_Wearable < RPG::Sprite
attr_accessor :filename
attr_accessor :action
attr_accessor :sprite
attr_accessor :must_adjust_scroll
def initialize(player_sprite, filename, action, viewport)
@player_sprite = player_sprite
@@ -17,8 +16,6 @@ class Sprite_Wearable < RPG::Sprite
@frameHeight = 80 #@sprite.height / 4
@sprite.z = 0
@relative_z=0 #relative to player
@map_scrolled=false #true if the map has scrolled, false if centered on the player
@must_adjust_scroll = false #todo temp fix for weird pokemart scrolling glitch
echoln(_INTL("init had at z = {1}, player sprite at {2}",@sprite.z,@player_sprite.z))
#Unused position offset
@@ -32,24 +29,24 @@ class Sprite_Wearable < RPG::Sprite
end
def adjustPositionForScreenScrolling
return if !$game_map.scrolling? && !(@map_scrolled && @must_adjust_scroll)
if $game_player.isCentered()
@map_scrolled=false
return
return if !$game_map.scrolling? && !@was_just_scrolling
if $game_map.scrolling?
@was_just_scrolling=true
else
@was_just_scrolling=false
end
@map_scrolled=true if @must_adjust_scroll
offset_x = 0
offset_y = 0
@sprite.z+=10
case $game_map.scroll_direction
when DIRECTION_RIGHT
offset_x=-8
when DIRECTION_LEFT
offset_x=8
when DIRECTION_UP
offset_y=16
offset_y=8
@sprite.z+=50 #weird layering glitch for some reason otherwise. It's reset to the correct value in the next animation frame
when DIRECTION_DOWN
offset_y=-16
offset_y=-8
end
@sprite.x+=offset_x
@sprite.y+=offset_y
@@ -125,8 +122,8 @@ class Sprite_Wearable < RPG::Sprite
current_frame = @player_sprite.character.pattern if !frame
direction = @player_sprite.character.direction
crop_spritesheet(direction)
set_sprite_position(@action, direction, current_frame)
adjust_layer()
set_sprite_position(@action, direction, current_frame)
end
def update(action, filename,color)

View File

@@ -17,10 +17,6 @@ class Sprite_Player < Sprite_Character
getClothedPlayerSprite(true)
end
def toggleWearableScrollAdjustments(value)
@hair.must_adjust_scroll = value
@hat.must_adjust_scroll = value
end
def updateCharacterBitmap
skinTone = $Trainer.skin_tone ? $Trainer.skin_tone : 0

View File

@@ -236,7 +236,6 @@ class PokemonMart_Scene
def pbStartBuyOrSellScene(buying, stock, adapter)
# Scroll right before showing screen
$scene.spritesetGlobal.playersprite.toggleWearableScrollAdjustments(true) # todo temp
scroll_map()
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@@ -278,8 +277,6 @@ class PokemonMart_Scene
@buying = buying
pbRefresh
Graphics.frame_reset
$scene.spritesetGlobal.playersprite.toggleWearableScrollAdjustments(false) # todo temp
end
def pbStartBuyScene(stock, adapter)
@@ -590,6 +587,7 @@ class PokemonMartScreen
@scene.pbStartBuyScene(@stock,@adapter)
item=nil
loop do
pbWait(4)
item=@scene.pbChooseBuyItem
break if !item
quantity=0