Main Menu
  • Welcome to The RPG Maker Resource Kit.

Sprite Problem

Started by da good king, May 30, 2009, 09:23:30 PM

0 Members and 1 Guest are viewing this topic.

da good king

 When I add a sprite to my scene, it is completely invisible unless it's x and y coords are > 0....Makes it hard to design when sprites cant touch the left or upper edge of the screen ever.

modern algebra

You put it out of the boundary and want it to be drawn? Try assigning a viewport to it.

SO Sprite_dfkndk.new (Viewport.new (0, 0, 544, 416))

da good king

#2
except whenever I assign a viewport, it disappears again...I never had this problem in XP either

src_rect works super funky too thanks to their goofy character graphic system..By that, I mean the width and height start from the left upper edge no matter what it's ox and oy are, which make it so it displays all character sprites to the left and above when I change the src_rect x and y. VX just stinks for this it seems. All I'm doing is printing a character graphic, and I'm getting trouble just printing a stationary sprite -_-

EDIT: So, I just took out the ox and oy, and replaced their use with @graphic_x and @graphic_y variables.

modern algebra

What are you trying to do this for? It doesn't sound like you need to be using a sprite, certainly not one that goes outside of the screen boundaries. And what is the code you're using?

da good king

 Well, I'm working on a Tactical game, and I'm trying to use my own sprites, (Sprite_Unit to be specific), and the sprites aren't in negative space or anything, the game just apparently won't print things unless theyre x and y are > 0. (Keep in mind there are obviously tiles and such that are printed at 0,0; it just doesnt seem to work for me for whatever reason.)

This is the code I've made thus far:

class Sprite_Unit < Sprite
  def initialize(unit)
    super()
    @unit = unit
    @direction = unit.direction
    @action = unit.action
    @pic_frame = 0
    self.bitmap = Cache.character(unit.actor.character_name)
    self.x = unit.x
    self.y = unit.y
    @graphic_x = unit.actor.character_index % 4 * 96
    @graphic_y = unit.actor.character_index / 4 * 128
    self.src_rect.set(@graphic_x, @graphic_y, 32, 32)
  end
   
  def update
    super
    case @action
    when "Standing";  update_standing
    end
  end
   def update_standing
    @pic_frame += 1
    @pic_frame = 0 if @pic_frame >= 60
    @pic_x = [0, 32, 64, 32]
    self.src_rect.x = @graphic_x + @pic_x[@pic_frame / 15]
    case @direction
    when "Down";  self.src_rect.y = @graphic_y
    when "Left";  self.src_rect.y = @graphic_y + 32
    when "Right"; self.src_rect.y = @graphic_y + 64
    when "Down";  self.src_rect.y = @graphic_y + 96
    end
  end
end


Note that if I use super(Viewport.new(0, 0, 544, 416)), nothing is printed, and yes, if self.x or self.y is 0, it doesn't print. Also, I originally used self.ox/y instead of graphic_x/y, but that didn't seem to work very well...

modern algebra

Well, you should use Sprite_Base since I would assume you will want to play animations.

But, that being said, Sprites definitely don't have a problem with being drawn at 0, 0 that I've ever encountered. The code you posted works fine for me, granting that I removed reference to the unit class and instead used an actor and set other things manually. It drew it at 0,0 without any problem. Are ou sure unit.x and unit.y are at 0, 0? Print it out before drawing maybe.

I don't know what else to say. It works in a project I made for testing purposes. I don't know why you can't draw sprites at 0, 0. If you send me the project that the error is occuring in, or else a project with the error reproduced, then I might be able to diagnose it from there. But nothing goes wrong for me.

da good king

i c, I may have to send you my project, as simply using
@sprite = Sprite.new
in a scene doesn't work unless I set a @spritex/y>0, which is how I became aware of the problem. I'll try making a new project and seeing if maybe I just accidentally messed with something.