Class: BattleUI::Cursor

Inherits:
ShaderedSprite show all
Defined in:
scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb

Overview

Sprite showing a cursor (being animated)

Instance Attribute Summary collapse

Attributes inherited from LiteRGSS::ShaderedSprite

#blendmode, #shader

Attributes inherited from LiteRGSS::Sprite

#__index__, #angle, #bitmap, #height, #mirror, #opacity, #ox, #oy, #src_rect, #viewport, #visible, #width, #x, #y, #z, #zoom, #zoom_x, #zoom_y

Instance Method Summary collapse

Methods inherited from Sprite

#load, #mouse_in?, #set_origin_div, #set_rect, #set_rect_div, #set_z, #simple_mouse_in?, #translate_mouse_coords

Methods inherited from LiteRGSS::Sprite

new, #set_origin, #set_position

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(viewport) ⇒ Cursor

Create a new cursor

Parameters:



14
15
16
17
18
19
20
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 14

def initialize(viewport)
  super(viewport)
  @origin_x = 0
  @origin_y = 0
  @target_x = 0
  @target_y = 0
end

Instance Attribute Details

#origin_x (readonly)

Get the origin x



5
6
7
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 5

def origin_x
  @origin_x
end

#origin_y (readonly)

Get the origin y



7
8
9
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 7

def origin_y
  @origin_y
end

#target_x (readonly)

Get the target x



9
10
11
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 9

def target_x
  @target_x
end

#target_y (readonly)

Get the target y



11
12
13
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 11

def target_y
  @target_y
end

Instance Method Details

#register_positions

Register the positions so the cursor can animate itself



23
24
25
26
27
28
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 23

def register_positions
  @origin_x = x
  @origin_y = y
  @target_x = x - 5
  @target_y = y
end

#start_animationYuki::Animation::TimedLoopAnimation

Create and start the cursor animation

Returns:

  • (Yuki::Animation::TimedLoopAnimation)


55
56
57
58
59
60
61
62
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 55

def start_animation
  root = Yuki::Animation::TimedLoopAnimation.new(1)
  root.play_before(Yuki::Animation.move(0.5, self, :origin_x, :origin_y, :target_x, :target_y))
  root.play_before(Yuki::Animation.move(0.5, self, :target_x, :target_y, :origin_x, :origin_y))
  root.resolver = self
  root.start
  return @animation = root
end

#stop_animation

Stops the animation



49
50
51
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 49

def stop_animation
  @animation = nil
end

#update

Update the sprite



31
32
33
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 31

def update
  @animation&.update
end

#visible=(visible)

Set the visibility

Parameters:

  • visible (Boolean)


37
38
39
40
41
42
43
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00106 Cursor.rb', line 37

def visible=(visible)
  return if self.visible == visible

  super
  stop_animation unless visible
  start_animation if visible
end