Class: Viewport

Inherits:
LiteRGSS::Viewport show all
Defined in:
docs/0_Dependencies.rb

Overview

Class that describes a surface of the screen where texts and sprites are shown (with some global effect)

Defined Under Namespace

Modules: WithToneAndColors

Constant Summary collapse

CONFIGS =

Hash containing all the Viewport configuration (:main, :sub etc...)

{}
VIEWPORT_CONF_COMP =

Filename for viewport compiled config

'Data/Viewport.rxdata'
VIEWPORT_CONF_TEXT =

Filename for viewport uncompiled config

'Data/Viewport.json'

Instance Attribute Summary collapse

Attributes inherited from LiteRGSS::Viewport

#__index__, #angle, #blendmode, #ox, #oy, #rect, #shader, #visible, #z, #zoom

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LiteRGSS::Viewport

#snap_to_bitmap, #sort_z

Methods inherited from LiteRGSS::Disposable

#disposed?

Constructor Details

#initialize(x, y, width, height, z = nil) ⇒ Viewport

Create a new viewport

Parameters:

  • x (Integer) —

    x coordinate of the viewport on screen

  • y (Integer) —

    y coordinate of the viewport on screen

  • width (Integer) —

    width of the viewport

  • height (Integer) —

    height of the viewport

  • z (Integer) (defaults to: nil) —

    z coordinate of the viewport



1290
1291
# File 'docs/0_Dependencies.rb', line 1290

def initialize(x, y, width, height, z = nil)
end

Instance Attribute Details

#need_to_sort ⇒ Boolean

Tell if the viewport needs to sort

Returns:

  • (Boolean)


1283
1284
1285
# File 'docs/0_Dependencies.rb', line 1283

def need_to_sort
  @need_to_sort
end

Class Method Details

.create(screen_name_symbol, z = nil) ⇒ Viewport .create(x, y = 0, width = 1, height = 1, z = nil) ⇒ Viewport .create(opts) ⇒ Viewport

Generating a viewport with one line of code

Overloads:

  • .create(screen_name_symbol, z = nil) ⇒ Viewport

    Parameters:

    • screen_name_symbol (:main, :sub) —

      describe with screen surface the viewport is (loaded from maker options)

    • z (Integer, nil) (defaults to: nil) —

      superiority of the viewport

  • .create(x, y = 0, width = 1, height = 1, z = nil) ⇒ Viewport

    Parameters:

    • x (Integer) —

      x coordinate of the viewport

    • y (Integer) (defaults to: 0) —

      y coordinate of the viewport

    • width (Integer) (defaults to: 1) —

      width of the viewport

    • height (Integer) (defaults to: 1) —

      height of the viewport

    • z (Integer, nil) (defaults to: nil) —

      superiority of the viewport

  • .create(opts) ⇒ Viewport

    Parameters:

    • opts (Hash) —

      opts of the viewport definition

    Options Hash (opts):

    • :x (Integer) — default: 0 —

      x coordinate of the viewport

    • :y (Integer) — default: 0 —

      y coordinate of the viewport

    • :width (Integer) — default: 320 —

      width of the viewport

    • :height (Integer) — default: 240 —

      height of the viewport

    • :z (Integer, nil) — default: nil —

      superiority of the viewport

Returns:



1315
1316
# File 'docs/0_Dependencies.rb', line 1315

def create(x, y = 0, width = 1, height = 1, z = 0)
end

.load_configs

Load the viewport configs



1318
1319
# File 'docs/0_Dependencies.rb', line 1318

def load_configs
end

Instance Method Details

#dispose ⇒ self

Dispose a viewport

Returns:

  • (self)


1294
1295
# File 'docs/0_Dependencies.rb', line 1294

def dispose
end

#flash(color, duration)

Flash the viewport

Parameters:



1327
1328
# File 'docs/0_Dependencies.rb', line 1327

def flash(color, duration)
end

#simple_mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Boolean

Detect if the mouse is in the sprite (without rotation and stuff like that)

Parameters:

  • mouse_x (Integer) (defaults to: Mouse.x) —

    the mouse x position on the screen

  • mouse_y (Integer) (defaults to: Mouse.y) —

    the mouse y position on the screen

Returns:

  • (Boolean)

Author:

  • Nuri Yuri



1426
1427
# File 'docs/0_Dependencies.rb', line 1426

def simple_mouse_in?(mouse_x = Mouse.x, mouse_y = Mouse.y)
end

#to_s Also known as: inspect

Format the viewport to string for logging purposes



1322
1323
# File 'docs/0_Dependencies.rb', line 1322

def to_s
end

#translate_mouse_coords(mouse_x = Mouse.x, mouse_y = Mouse.y) ⇒ Array(Integer, Integer)

Convert mouse coordinate on the screen to mouse coordinates on the sprite

Parameters:

  • mouse_x (Integer) (defaults to: Mouse.x) —

    the mouse x position on the screen

  • mouse_y (Integer) (defaults to: Mouse.y) —

    the mouse y position on the screen

Returns:

  • (Array(Integer, Integer)) —

    the mouse coordinates on the sprite

Author:

  • Nuri Yuri



1433
1434
# File 'docs/0_Dependencies.rb', line 1433

def translate_mouse_coords(mouse_x = Mouse.x, mouse_y = Mouse.y)
end

#update

Update the viewport



1330
1331
# File 'docs/0_Dependencies.rb', line 1330

def update
end