じ☆ve冰风 发表于 7 天前

Problem manipulating viewport for big enemy battler sprite

                        I was debating whether to post about this error in the "general" support section or here, but since I'm already trying to work with the scripts directly, here seems more ideal.                
Click to expand...


I was trying to manipulate some data to change the battle presentation of the windows, not too fancy, just to make it look a bit different. So, something like the following:





But, when trying to change it this way, I found a problem with how the viewport seems to work.

I created a copy of class Spriteset_Battle so I could change the viewport of the battleback

                Ruby:        
class Spriteset_Battle   # Default comments etc...   def initialize   # Make viewports   @viewport1 = Viewport.new(0, 0, 440, 480) # The original was 640, 320 iirc #some code...   end          def update   # Update actor sprite contents (corresponds with actor switching)   # some code...   @battleback_sprite.src_rect.set(0, 0, 440, 480) #same change


This is what I changed so it would fit the new resolution for the battleback. However, when I tried to change the viewport relevant to the enemy (creating its own viewport even) with a bigger sprite, it showed it self as a cropped sprite.




This does make sense honestly, but now i'm kinda confused. What would be the best way to change this so it accommodates larges sprites? For some reason, on the Troops editor, I can only move the sprite beyond the TOP of the editor, not below, which is kinda silly honestly and its what its making this a headache...


The important part that makes this changes is as follows:
                Ruby:        
class Spriteset_Battle   #--------------------------------------------------------------------------   # * Public Instance Variables   #--------------------------------------------------------------------------   attr_reader   :viewport1                # enemy viewport   attr_reader   :viewport2                # actor viewport   #--------------------------------------------------------------------------   # * Object Initialization   #--------------------------------------------------------------------------   def initialize   # Make viewports   @viewport1 = Viewport.new(0, 0, 440, 480)   @viewport2 = Viewport.new(0, 0, 640, 480)   @viewport3 = Viewport.new(0, 0, 640, 480)   @viewport4 = Viewport.new(0, 0, 640, 480)   @viewport5 = Viewport.new(0, 120, 600, 480) # putting a "offset" on y parameter, so it moves the view to centralize its display based on what the editor shows   @viewport2.z = 101   @viewport3.z = 200   @viewport4.z = 5000   # Make battleback sprite   @battleback_sprite = Sprite.new(@viewport1)   # Make enemy sprites   @enemy_sprites = []   for enemy in $game_troop.enemies.reverse       @enemy_sprites.push(Sprite_Battler.new(@viewport5, enemy))


I thought about changing the Battler class itself, but i'm still trying to understand how some functions work, specially the ones that doesnt seem to be editable, and I was afraid to break other stuff that is already working.

If there's any additional advice to make it easier to understand the code and specially to know where each methods are (since the search is per file, not for all scripts) I would appreciate a lot as well. Thanks!


本贴来自国际rpgmaker官方论坛作者:OmaruS处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/problem-manipulating-viewport-for-big-enemy-battler-sprite.183223/
页: [1]
查看完整版本: Problem manipulating viewport for big enemy battler sprite