Main Menu
  • Welcome to The RPG Maker Resource Kit.

[Resolved] Image Rotation with Alternate axis?

Started by shintashi, October 16, 2011, 03:10:42 AM

0 Members and 1 Guest are viewing this topic.

shintashi

Say I have a picture and I want it to rotate about a portion that isn't its center or 0,0 coordinate. How would I do that? In flash I just double click inside the movie clip and move the image so the 'center' of gravity is where ever I want it, but in Ruby, I have no clue.

shintashi

supposedly this centers stuff "sprite.ox = sprite.bitmap.width / 2, sprite.oy = sprite.bitmap.height / 2. "

and something like angle (out of 360) sets rotation. I'll have to do some testing soon, after I find a direct line of code for rotation.

cozziekuns

Yeah, just change the ox and oy values.

shintashi

#3
Quote from: cozziekuns on October 16, 2011, 03:44:39 AM
Yeah, just change the ox and oy values.

but there's no ox or oy values for pictures?


#==============================================================================
# ** Game_Picture
#------------------------------------------------------------------------------
#  This class handles the picture. It's used within the Game_Screen class
#  ($game_screen).
#==============================================================================

class Game_Picture
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :number                   # picture number
  attr_reader   :name                     # file name
  attr_reader   :origin                   # starting point
  attr_reader   :x                        # x-coordinate
  attr_reader   :y                        # y-coordinate
  attr_reader   :zoom_x                   # x directional zoom rate
  attr_reader   :zoom_y                   # y directional zoom rate
  attr_reader   :opacity                  # opacity level
  attr_reader   :blend_type               # blend method
  attr_reader   :tone                     # color tone
  attr_reader   :angle                    # rotation angle
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     number : picture number
  #--------------------------------------------------------------------------
  def initialize(number)
    @number = number
    @name = ""
    @origin = 0
    @x = 0.0
    @y = 0.0
    @zoom_x = 100.0
    @zoom_y = 100.0
    @opacity = 255.0
    @blend_type = 1
    @duration = 0
    @target_x = @x
    @target_y = @y
    @target_zoom_x = @zoom_x
    @target_zoom_y = @zoom_y
    @target_opacity = @opacity
    @tone = Tone.new(0, 0, 0, 0)
    @tone_target = Tone.new(0, 0, 0, 0)
    @tone_duration = 0
    @angle = 0
    @rotate_speed = 0
  end
  #--------------------------------------------------------------------------
  # * Show Picture
  #     name       : file name
  #     origin     : starting point
  #     x          : x-coordinate
  #     y          : y-coordinate
  #     zoom_x     : x directional zoom rate
  #     zoom_y     : y directional zoom rate
  #     opacity    : opacity level
  #     blend_type : blend method
  #--------------------------------------------------------------------------
  def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
    @name = name
    @origin = origin
    @x = x.to_f
    @y = y.to_f
    @zoom_x = zoom_x.to_f
    @zoom_y = zoom_y.to_f
    @opacity = opacity.to_f
    @blend_type = blend_type
    @duration = 0
    @target_x = @x
    @target_y = @y
    @target_zoom_x = @zoom_x
    @target_zoom_y = @zoom_y
    @target_opacity = @opacity
    @tone = Tone.new(0, 0, 0, 0)
    @tone_target = Tone.new(0, 0, 0, 0)
    @tone_duration = 0
    @angle = 0
    @rotate_speed = 0
  end
  #--------------------------------------------------------------------------
  # * Move Picture
  #     duration   : time
  #     origin     : starting point
  #     x          : x-coordinate
  #     y          : y-coordinate
  #     zoom_x     : x directional zoom rate
  #     zoom_y     : y directional zoom rate
  #     opacity    : opacity level
  #     blend_type : blend method
  #--------------------------------------------------------------------------
  def move(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
    @duration = duration
    @origin = origin
    @target_x = x.to_f
    @target_y = y.to_f
    @target_zoom_x = zoom_x.to_f
    @target_zoom_y = zoom_y.to_f
    @target_opacity = opacity.to_f
    @blend_type = blend_type
  end
  #--------------------------------------------------------------------------
  # * Change Rotation Speed
  #     speed : rotation speed
  #--------------------------------------------------------------------------
  def rotate(speed)
    @rotate_speed = speed
  end
  #--------------------------------------------------------------------------
  # * Start Change of Color Tone
  #     tone     : color tone
  #     duration : time
  #--------------------------------------------------------------------------
  def start_tone_change(tone, duration)
    @tone_target = tone.clone
    @tone_duration = duration
    if @tone_duration == 0
      @tone = @tone_target.clone
    end
  end
  #--------------------------------------------------------------------------
  # * Erase Picture
  #--------------------------------------------------------------------------
  def erase
    @name = ""
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @duration >= 1
      d = @duration
      @x = (@x * (d - 1) + @target_x) / d
      @y = (@y * (d - 1) + @target_y) / d
      @zoom_x = (@zoom_x * (d - 1) + @target_zoom_x) / d
      @zoom_y = (@zoom_y * (d - 1) + @target_zoom_y) / d
      @opacity = (@opacity * (d - 1) + @target_opacity) / d
      @duration -= 1
    end
    if @tone_duration >= 1
      d = @tone_duration
      @tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
      @tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
      @tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
      @tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
      @tone_duration -= 1
    end
    if @rotate_speed != 0
      @angle += @rotate_speed / 2.0
      while @angle < 0
        @angle += 360
      end
      @angle %= 360
    end
  end
end




Edit....

wait...

there's


#==============================================================================
# ** Sprite_Picture
#------------------------------------------------------------------------------
#  This sprite is used to display the picture.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Picture < Sprite
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport : viewport
  #     picture  : picture (Game_Picture)
  #--------------------------------------------------------------------------
  def initialize(viewport, picture)
    super(viewport)
    @picture = picture
    update
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If picture file name is different from current one
    if @picture_name != @picture.name
      # Remember file name to instance variables
      @picture_name = @picture.name
      # If file name is not empty
      if @picture_name != ""
        # Get picture graphic
        self.bitmap = RPG::Cache.picture(@picture_name)
      end
    end
    # If file name is empty
    if @picture_name == ""
      # Set sprite to invisible
      self.visible = false
      return
    end
    # Set sprite to visible
    self.visible = true
    # Set transfer starting point
    if @picture.origin == 0
      self.ox = 0
      self.oy = 0
    else
      self.ox = self.bitmap.width / 2
      self.oy = self.bitmap.height / 2
    end
    # Set sprite coordinates
    self.x = @picture.x
    self.y = @picture.y
    self.z = @picture.number
    # Set zoom rate, opacity level, and blend method
    self.zoom_x = @picture.zoom_x / 100.0
    self.zoom_y = @picture.zoom_y / 100.0
    self.opacity = @picture.opacity
    self.blend_type = @picture.blend_type
    # Set rotation angle and color tone
    self.angle = @picture.angle
    self.tone = @picture.tone
  end
end


ok, I guess I'll try messing with it. First step is to see if I can display a picture without using eventing - via some short script...(i.e. I still don't know what I'm doing yet, but Im closer)

cozziekuns

You can always make your own, and then alter it using script calls:


class Game_Picture

  attr_reader   :ox
  attr_reader   :oy

  alias coz_shin_angling_gp_initialize initialize
  def initialize(*args)
    coz_shin_angling_gp_intialize(*args)
    @ox = 0
    @oy = 0
  end

end


And then alter Sprite_Picture. Finally, you can make script calls by setting pictures public and using:


$game_screen.pictures[number].ox = blah
$game_screen.pictures[number].oy = blah


shintashi

I see. Right now I'm trying to turn 10 images into part of a special menu. While I've got three separate parts that have to rotate, I'm worried about four things:

1. I have one image for an arrow but I need three copies on the screen (should I make two more copies?)
2. I need to properly layer these images, and I'm hoping I can personally set each z coordinate
3. I forsee the instant/always on problem coming
4. I need to be able to dispose of all these images


to give you an idea, this is about as far as my image programming goes:


@sprite = Sprite.new
@sprite.z, @sprite.x, @sprite.y =
120, 160, 0

@sprite.bitmap =
RPG::Cache.picture ("arrows")


and that's largely a rip off of something I programmed last year while learning from a tutorial.

shintashi


@sprite = Sprite.new
@sprite.z, @sprite.x, @sprite.y =
120, 160, 200
@sprite.angle = 40
@sprite.bitmap =
RPG::Cache.picture ("arrowR")

p @sprite.rotate_speed


Everything works except the last line...I tried @sprite.rotate_speed = 1, but it crashed. Apparently even though rotate_speed exists, it can't be accessed or is thought to exist.

cozziekuns

Game_Picture is totally independant of Cache.picture. Look up the sprite class instead.

modern algebra

#8
@rotate_speed does not exist in the Sprite class. It exists in the Game_Picture class, because this is how that class handles rotation in the update method:


    if @rotate_speed != 0
      @angle += @rotate_speed / 2.0
      while @angle < 0
        @angle += 360
      end
      @angle %= 360
    end


To rotate a sprite like in your example, you need to change the angle directly, and that will require frame updating.

shintashi

#9
I was afraid of that.

can a frame update fit inside the little eventing script editor?

I'm guessing not:


@sprite = Sprite.new
@sprite.z, @sprite.x, @sprite.y =
120, 160, 200
@sprite.angle = 40
@sprite.bitmap =
RPG::Cache.picture ("arrowR")
ab = Graphics.frame_count
bb = Graphics.frame_rate
if ab / bb != @total_sec
@sprite.angle += 1
end


was all I could fit in there and the last lines didn't seem to work. I also noticed if I load more than one image - even ones with different depth and names, the computer makes all but the last disappear, but when stacked on top of each other they get 'thicker' and then "thin out' like they are loading on top of each other then vanishing. I'm hoping there's a way around that and I think it has something to do with update and refresh. Clearly this is going to be a whole new Class.

modern algebra

It would certainly be possible, though unwise. Why are you restricting yourself to events?

In any case, one way to do it would be to make the sprite a local instance variable, and then you could have a parallel process where you just perform the update.

But it's not a smart way to do it. You're making this way harder for yourself than it has any reason to be. You could just add the ox and oy attributes to Game_Picture and add something to Sprite Picture to mirror those attributes, and then you could do almost everything through the default event commands for controlling pictures. All you'd need to do through the script event command is set the ox and oy to whatever you want it to be.


shintashi

Quote from: modern algebra on October 16, 2011, 05:54:46 PM
It would certainly be possible, though unwise. Why are you restricting yourself to events?

In any case, one way to do it would be to make the sprite a local instance variable, and then you could have a parallel process where you just perform the update.

But it's not a smart way to do it. You're making this way harder for yourself than it has any reason to be. You could just add the ox and oy attributes to Game_Picture and add something to Sprite Picture to mirror those attributes, and then you could do almost everything through the default event commands for controlling pictures. All you'd need to do through the script event command is set the ox and oy to whatever you want it to be.



My goal is to make a new menu that will appear during battle, made up of 12 separate images.
3 images will rotate on command
3 images will move left or right
6 images are stationary

the layer depth is also important. I just wanted to test the most basic functions using event script, to see if I could do each of the functions. Right now i can't adjust my center of gravity  until i can get an object to rotate. I thought it would be faster to get the ox oy corrections through a small event script.

shintashi

well i got 11 of the 12 images uploaded through Scene Battle, and now I have try to rotate some of them and correct for ox and oy, which I have like, no clue how to do... wish me luck

LoganF

Whilst it is a solution, I'm not sure how efficient it is. Also, graphical things are something I've only just started getting into so my knowledge around the Sprite related classes is limited.

[spoiler=Custom Axis]
class Game_Picture
 
  attr_accessor  :ox
  attr_accessor  :oy
 
  alias shin_picrotcu_init_tr8a initialize
  def initialize(*args)
    shin_picrotcu_init_tr8a(*args)
    @ox = 0
    @oy = 0
  end
 
  #requires bitmap width and bitmap height - called from Sprite_Picture
  def update_origin(bmw, bmh)
    if ( (@ox == 0) && (@oy == 0) ) #top left origin
      @origin = 0
    elsif ( (@ox == bmw / 2) && (oy == bmh / 2) ) #center origin
      @origin = 1
    else
      @origin = 2 #custom origin
    end
  end
 
end

class Sprite_Picture < Sprite

  #overwrite update; added some code (see comments below)
  def update
    super
    if @picture_name != @picture.name
      @picture_name = @picture.name
      if @picture_name != ""
        self.bitmap = Cache.picture(@picture_name)
      end
    end
    if @picture_name == ""
      self.visible = false
    else
      self.visible = true
      @picture.update_origin(self.bitmap.width, self.bitmap.height) #auto set origin based on parameters
      if @picture.origin == 0
        self.ox = 0
        self.oy = 0
      elsif @picture.origin == 1 #changed to prevent resetting of origin
        self.ox = self.bitmap.width / 2
        self.oy = self.bitmap.height / 2
      else
        self.ox = @picture.ox #picture's ox
        self.oy = @picture.oy #picture's oy
      end
      self.x = @picture.x
      self.y = @picture.y
      self.z = 100 + @picture.number
      self.zoom_x = @picture.zoom_x / 100.0
      self.zoom_y = @picture.zoom_y / 100.0
      self.opacity = @picture.opacity
      self.blend_type = @picture.blend_type
      self.angle = @picture.angle
      self.tone = @picture.tone
    end
  end
 
end

[/spoiler]

Made simply by following Cozzie's method he first put up and modern's always useful advice on having Sprite_Picture reflect those new parameters.

Sprite_Picture normally sets the ox and oy (Sprites already have this parameter) based on the origin option selected in the Show Picture command. 0 is Top Left and any other value (it uses 1 but it's irrelevant) sets the ox and oy to the centre of the bitmap/sprite. I had to change the way the update is handled, so that 1 is now always centre origin, and any other value is the ox and oy value of the Picture itself.

All you need to do is set the ox and oy values via the script command:


screen.pictures[n].ox = blah
screen.pictures[n].oy = blah


This also points out a small mistake in Cozzie's snippets.

$game_screen isn't defined as such, but Game_Interpreter has a method called screen that acts as the same thing*. Also, ox and oy need to be accessors or writers to allow writing to it. Reader won't work but he already knows that I'm sure.

There's probably a better way around this but it should do.

*Random info: There's two kinds of screens; $game_map.screen and $game_troop.screen. You could access the pictures shown on the map via $game_map.screen.pictures[n] but it's unnecessary since Game_Interpreter does that for you. Same for $game_troop.screen for pictures shown in battles. Useful to know... perhaps.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

shintashi

well after hours of fiddling with +/- 1-2 pixels at a time, I came up with this:



def make_triangle
    y_mod = 25
    # triangle background
      @sprite8 = Sprite.new
    @sprite8.z, @sprite8.x, @sprite8.y = 115, 477, 280 + y_mod
    @sprite8.angle = 0 #keep 0
    @sprite8.bitmap = RPG::Cache.picture ("tri_circle")
   
    # get actor
    @active_battler = $game_party.actors[@actor_index]
   
    # x_rotate
      @sprite9 = Sprite.new
    @sprite9.z, @sprite9.x, @sprite9.y = 116, 555, 306 + y_mod
    @sprite9.angle = 0 + @active_battler.spd
    @sprite9.ox = 6
    @sprite9.oy = 6
    @sprite9.bitmap = RPG::Cache.picture ("x_rotate")
    # y_rotate
      @sprite10 = Sprite.new
    @sprite10.z, @sprite10.x, @sprite10.y = 117, 503 +6, 381 + y_mod
    @sprite10.angle = 0 + @active_battler.uke
    @sprite10.ox = 6
    @sprite10.oy = 47
    @sprite10.bitmap = RPG::Cache.picture ("y_rotate")
    #z_rotate
      @sprite11 = Sprite.new
    @sprite11.z, @sprite11.x, @sprite11.y = 118, 525 +69, 383 + y_mod
    @sprite11.angle = 0 + @active_battler.agg
    @sprite11.ox = 69
    @sprite11.oy = 52
    @sprite11.bitmap = RPG::Cache.picture ("z_rotate")
   
   
    #tri_cover
      @sprite12 = Sprite.new
    @sprite12.z, @sprite12.x, @sprite12.y = 119, 497, 290 + y_mod
    @sprite12.angle = 0 #keep 0
    @sprite12.bitmap = RPG::Cache.picture ("tri_cover")

  end
  #--------------------------------------------------------------------------
  # * Make Bars (initiative, semeru, brutality, arrowR, arrowG, arrowB)
  #--------------------------------------------------------------------------
  def make_bars
   
    # get actor
    @active_battler = $game_party.actors[@actor_index]
    # @active_battler.name
    abs = @active_battler.spd
    abu = @active_battler.uke
    aba = @active_battler.agg
   
    y_mod = 25
    # initiative <=> patience (impulsive/intercept)
      @sprite1 = Sprite.new
    @sprite1.z, @sprite1.x, @sprite1.y = 120, 260, 274 + y_mod
    @sprite1.angle = 0
    @sprite1.bitmap = RPG::Cache.picture ("yellow_blue")
    # semeru <=> ukeru (forceful/receiving)
      @sprite2 = Sprite.new
    @sprite2.z, @sprite2.x, @sprite2.y = 121, 261, 348 + y_mod
    @sprite2.angle = 0
    @sprite2.bitmap = RPG::Cache.picture ("indigo_green")
    # brutality <=> finesse (bloody/accurate)   
      @sprite3 = Sprite.new
    @sprite3.z, @sprite3.x, @sprite3.y = 122, 260, 376 + y_mod
    @sprite3.angle = 0
    @sprite3.bitmap = RPG::Cache.picture ("red_orange")
    #arrowB
          @sprite4 = Sprite.new
    @sprite4.z, @sprite4.x, @sprite4.y = 123, 346 + abs, 334 + y_mod
    @sprite4.angle = 0
    @sprite4.bitmap = RPG::Cache.picture ("arrowB")
    #arrowG
          @sprite5 = Sprite.new
    @sprite5.z, @sprite5.x, @sprite5.y = 123, 346 + abu, 362 + y_mod
    @sprite5.angle = 0
    @sprite5.bitmap = RPG::Cache.picture ("arrowG")
    #arrowR
          @sprite6 = Sprite.new
    @sprite6.z, @sprite6.x, @sprite6.y = 124, 346 + aba, 391 + y_mod
    @sprite6.angle = 0
    @sprite6.bitmap = RPG::Cache.picture ("arrowR")   
    #black rectangle status display
            @sprite7 = Sprite.new
    @sprite7.z, @sprite7.x, @sprite7.y = 125, 260, 402 + y_mod
    @sprite7.angle = 0
    @sprite7.bitmap = RPG::Cache.picture ("black_rectangle")   

  end




I need to stick some text over the black_rectangle image, namely these things:


    @active_battler.name
   @active_battler.spd
   @active_battler.uke
   @active_battler.agg


plus some numerically derived terms (like if 3, 6, 9 ... "good, better, best" type stuff)

I have yet to figure out how to dispose of the images once displayed, but I at least figured out how to keep all but the last image from vanishing - by creating 'sprite1,sprite2...spriteN" instead of "sprite".

shintashi

so I've 'updated' it, but I think I screwed up in several places:


#==============================================================================
# ** Scene Battle Strategy
#------------------------------------------------------------------------------
#  This class performs battle strategy screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Start Strategy (make sure @battler is_an_actor? = true)
  #--------------------------------------------------------------------------
  def start_strategy
    #load background window overlay with actor's name
    #load arrow key readers
    @triangle_step = 1
    update_triangle
  end
  #--------------------------------------------------------------------------
  # * Make Triangle (circle, x_rotate, y_rotate, z_rotate, triangle lid)
  #--------------------------------------------------------------------------
  def make_triangle
    y_mod = 25
    # triangle background
      @sprite8 = Sprite.new
    @sprite8.z, @sprite8.x, @sprite8.y = 115, 477, 280 + y_mod
    @sprite8.angle = 0 #keep 0
    @sprite8.bitmap = RPG::Cache.picture ("tri_circle")
   
    # get actor
    @active_battler = $game_party.actors[@actor_index]
   
    # x_rotate
      @sprite9 = Sprite.new
    @sprite9.z, @sprite9.x, @sprite9.y = 116, 555, 306 + y_mod
    @sprite9.angle = 0 + @active_battler.spd
    @sprite9.ox = 6
    @sprite9.oy = 6
    @sprite9.bitmap = RPG::Cache.picture ("x_rotate")
    # y_rotate
      @sprite10 = Sprite.new
    @sprite10.z, @sprite10.x, @sprite10.y = 117, 503 +6, 381 + y_mod
    @sprite10.angle = 0 + @active_battler.uke
    @sprite10.ox = 6
    @sprite10.oy = 47
    @sprite10.bitmap = RPG::Cache.picture ("y_rotate")
    #z_rotate
      @sprite11 = Sprite.new
    @sprite11.z, @sprite11.x, @sprite11.y = 118, 525 +69, 383 + y_mod
    @sprite11.angle = 0 + @active_battler.agg
    @sprite11.ox = 69
    @sprite11.oy = 52
    @sprite11.bitmap = RPG::Cache.picture ("z_rotate")
   
   
    #tri_cover
      @sprite12 = Sprite.new
    @sprite12.z, @sprite12.x, @sprite12.y = 119, 497, 290 + y_mod
    @sprite12.angle = 0 #keep 0
    @sprite12.bitmap = RPG::Cache.picture ("tri_cover")

  end
  #--------------------------------------------------------------------------
  # * Make Bars (initiative, semeru, brutality, arrowR, arrowG, arrowB)
  #--------------------------------------------------------------------------
  def make_bars
   
    # get actor
    @active_battler = $game_party.actors[@actor_index]
    # @active_battler.name
    abs = @active_battler.spd
    abu = @active_battler.uke
    aba = @active_battler.agg
   
    y_mod = 25
    # initiative <=> patience (impulsive/intercept)
      @sprite1 = Sprite.new
    @sprite1.z, @sprite1.x, @sprite1.y = 120, 260, 274 + y_mod
    @sprite1.angle = 0
    @sprite1.bitmap = RPG::Cache.picture ("yellow_blue")
    # semeru <=> ukeru (forceful/receiving)
      @sprite2 = Sprite.new
    @sprite2.z, @sprite2.x, @sprite2.y = 121, 261, 348 + y_mod
    @sprite2.angle = 0
    @sprite2.bitmap = RPG::Cache.picture ("indigo_green")
    # brutality <=> finesse (bloody/accurate)   
      @sprite3 = Sprite.new
    @sprite3.z, @sprite3.x, @sprite3.y = 122, 260, 376 + y_mod
    @sprite3.angle = 0
    @sprite3.bitmap = RPG::Cache.picture ("red_orange")
    #arrowB
          @sprite4 = Sprite.new
    @sprite4.z, @sprite4.x, @sprite4.y = 123, 346 + abs, 334 + y_mod
    @sprite4.angle = 0
    @sprite4.bitmap = RPG::Cache.picture ("arrowB")
    #arrowG
          @sprite5 = Sprite.new
    @sprite5.z, @sprite5.x, @sprite5.y = 123, 346 + abu, 362 + y_mod
    @sprite5.angle = 0
    @sprite5.bitmap = RPG::Cache.picture ("arrowG")
    #arrowR
          @sprite6 = Sprite.new
    @sprite6.z, @sprite6.x, @sprite6.y = 124, 346 + aba, 391 + y_mod
    @sprite6.angle = 0
    @sprite6.bitmap = RPG::Cache.picture ("arrowR")   
    #black rectangle status display
            @sprite7 = Sprite.new
    @sprite7.z, @sprite7.x, @sprite7.y = 125, 260, 402 + y_mod
    @sprite7.angle = 0
    @sprite7.bitmap = RPG::Cache.picture ("black_rectangle")   

    #you need to stick the +/- 1-10 + text. over black_rectangle
    #   may need a Window_BlackText to make it happen.
  end
  #--------------------------------------------------------------------------
  # * Frame Update (triangle lines and bar arrows move when updated)
  #--------------------------------------------------------------------------
#probably an index loop starting with a case = 1, ++ with up/down
 
  def update_triangle
    case @triangle_step
    when 1
      update_triangle_step1
    when 2
      update_triangle_step2
    when 3
      update_triangle_step3
    end
  end

  #--------------------------------------------------------------------------
  # * Arrows Verticle: UP & DOWN
  #--------------------------------------------------------------------------
  def arrows_verticle
    if Input.repeat?(Input::UP) and @triangle_step > 1
      $game_system.se_play($data_system.cursor_se)
      @triangle_step -= 1
      refresh
    end
   
    if Input.repeat?(Input::DOWN) and @triangle_step < 3
      $game_system.se_play($data_system.cursor_se)
      @triangle_step += 1
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Strategy Option 1)
  #--------------------------------------------------------------------------
  def update_triangle_step1
    #changes @active_battler.spd with left/right
    arrows_verticle #may want this in refresh
    #define active battler
    @active_battler = $game_party.actors[@actor_index]
     
    if Input.repeat?(Input::LEFT) and @active_battler.spd > -10
      $game_system.se_play($data_system.cursor_se)
       @active_battler.spd -= 1
      refresh
    end

    if Input.repeat?(Input::RIGHT) and @active_battler.spd < 10
      $game_system.se_play($data_system.cursor_se)
      @active_battler.spd += 1
      refresh
    end

    #Confirm Choices and Exit
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      make_strategy_result
    end
   
    # if you backspace, you want to reset "strategy" to temp values.
    # this means you need a "temp" container
    # i think the temp container-back space option is the hardest part...
   
    #refresh display => probably could become a "refresh" def
    #C button to confirm all three bars info
    #if C button, then makebar/maketri/update tri
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Strategy Option 2)
  #--------------------------------------------------------------------------
  def update_triangle_step2
    #changes @active_battler.uke with left/right
    arrows_verticle
     #define active battler
    @active_battler = $game_party.actors[@actor_index]
   
    if Input.repeat?(Input::LEFT) and @active_battler.uke > -10
      $game_system.se_play($data_system.cursor_se)
       @active_battler.uke -= 1
      refresh
    end

   if Input.repeat?(Input::RIGHT) and @active_battler.uke < 10
      $game_system.se_play($data_system.cursor_se)
      @active_battler.uke += 1
      refresh
    end

    #Confirm Choices and Exit
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      make_strategy_result
    end

   
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Strategy Option 3)
  #--------------------------------------------------------------------------
  def update_triangle_step3
    #changes @active_battler.agg with left/right
    arrows_verticle
   
     #define active battler
    @active_battler = $game_party.actors[@actor_index]
   
    if Input.repeat?(Input::LEFT) and @active_battler.agg > -10
      $game_system.se_play($data_system.cursor_se)
       @active_battler.agg -= 1
      refresh
    end

   if Input.repeat?(Input::RIGHT) and @active_battler.agg < 10
      $game_system.se_play($data_system.cursor_se)
      @active_battler.agg += 1
      refresh
    end
         
    #Confirm Choices and Exit
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      make_strategy_result
    end
   
  end
  #--------------------------------------------------------------------------
  # * Refresh - may cause interference: alt: "strategy_refresh"
  #--------------------------------------------------------------------------
  def refresh # may crash
    make_bars
    make_triangle
    update_triangle
  end
  #--------------------------------------------------------------------------
  # * Make Strategy Results (Game Battler: attr accessor(s) for @actor)
  #--------------------------------------------------------------------------
  def make_strategy_result
    #lock values in place
    #  this def is a result of the C button from "update_triangle_step1-3"
   
    #dispose of these windows and bitmaps (may crash)
    @sprite1.dispose
    @sprite2.dispose
    @sprite3.dispose
    @sprite4.dispose
    @sprite5.dispose
    @sprite6.dispose
    @sprite7.dispose
    @sprite8.dispose
    @sprite9.dispose
    @sprite10.dispose
    @sprite11.dispose
    @sprite12.dispose
    # Go to command input for next actor
    phase3_next_actor
  end
end




some of the problems I'm experiencing:
it reads all the button pushing simultaneously - so as soon as I select the "strategy" and load these options, it also reads the


    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      make_strategy_result
    end


which then immediately loads the "phase3_next_actor" and '@sprite.dispose'.

finally, The arrow keys UP/DOWN/LEFT/RIGHT are still being used by Command menu instead of my script.



shintashi

ok, so i haven't figured out how to access the arrow keys yet, but I've got the idea on the spacebar to open the program also activating itself.

Basically, everything is running at once, and then stops. I think I need some kind of for loop. All this has to be done before I can test the image rotation.

Basically, the idea is by pushing the left or right keys, one of the objects on the screen rotates, while another moves left or right, and a sound plays acknowledging a button has been pushed.

Unfortunately, when I push the buttons, nothing happens. Neither Rotation nor Movement along the X axis.

shintashi

ok, so i think the problem im running into is based on the interface of the Window_Selectable update section of arrow keys.

I want to use arrow keys somewhat similar to the shop structure, without worrying about index values, but it seems like it wants a window to base my loops on.