This document provides an overview of the classes, methods, and properties defined in the rpg_core.js file for RPG Maker MV.
This section adds utility methods to standard JavaScript objects.
Number.prototype.clamp(min, max): Returns a number limited to the given range (min, max).Number.prototype.mod(n): Returns a modulo value that is always positive.Number.prototype.padZero(length): Converts a number to a string with leading zeros.String.prototype.format(...args): Replaces placeholders like %1, %2 with arguments in a string.String.prototype.padZero(length): Adds leading zeros to a string representation of a number.String.prototype.contains(string): Checks if a string contains another string.Array.prototype.equals(array): Checks if two arrays are the same.Array.prototype.clone(): Creates a shallow copy of the array.Array.prototype.contains(element): Checks if an array contains a specific element.Math.randomInt(max): Generates a random integer between 0 and max-1.
A static class containing various utility methods.
RPGMAKER_NAME: Constant, 'MV'.RPGMAKER_VERSION: Constant, '1.6.1'.isOptionValid(name): Checks if an option is present in the query string or NW.js arguments.isNwjs(): Checks if the platform is NW.js.isMobileDevice(): Checks if the platform is a mobile device.isMobileSafari(): Checks if the browser is Mobile Safari.isAndroidChrome(): Checks if the browser is Android Chrome.canReadGameFiles(): Checks if the browser can read files in the game folder.rgbToCssColor(r, g, b): Converts RGB values to a CSS color string.generateRuntimeId(): Generates a unique runtime ID.isSupportPassiveEvent(): Detects if the browser supports passive event listeners.
CacheEntry(cache, key, item): Represents a resource entry in the cache. It tracks usage and time-to-live (TTL).free(byTTL): Frees the resource.allocate(): Allocates the resource in the cache.setTimeToLive(ticks, seconds): Sets the TTL for the entry.isStillAlive(): Checks if the entry's TTL has expired.touch(): Resets the TTL timer for the entry.
CacheMap(manager): Manages a cache of resources (like images, audio) usingCacheEntry.checkTTL(): Checks and removes expired entries.getItem(key): Retrieves an item from the cache.clear(): Frees all entries in the cache.setItem(key, item): Adds or updates an item in the cache.update(ticks, delta): Updates cache timers and performs TTL checks.
ImageCache(): A specific cache implementation for Bitmaps.limit: Static property defining the cache size limit.add(key, value): Adds a bitmap to the cache.get(key): Retrieves a bitmap, updating its touch time.reserve(key, value, reservationId): Reserves a bitmap, preventing it from being purged easily.releaseReservation(reservationId): Releases a reservation.isReady(): Checks if all non-request-only bitmaps in the cache are loaded.getErrorBitmap(): Returns the first bitmap in the cache that encountered a loading error.
RequestQueue(): Manages loading requests for resources, ensuring they load sequentially.enqueue(key, value): Adds a resource request to the queue.update(): Processes the queue, starting the next request when the current one is ready.raisePriority(key): Moves a specific request to the front of the queue.clear(): Clears the request queue.
Point(x, y): Represents a 2D point (inherits fromPIXI.Point).Rectangle(x, y, width, height): Represents a rectangle (inherits fromPIXI.Rectangle).Bitmap(width, height): Represents an image. Handles loading, drawing, and manipulation operations.- Loading States:
none,pending,purged,requesting,requestCompleted,decrypting,decryptCompleted,loaded,error. - Static Methods:
load(url): Creates a Bitmap and starts loading the image from the URL.snap(stage): Takes a snapshot of the game screen.
- Properties:
url,baseTexture,canvas,context,width,height,rect,smooth,paintOpacity,fontFace,fontSize,fontItalic,textColor,outlineColor,outlineWidth. - Methods:
isReady(): Checks if the bitmap is loaded and ready.isError(): Checks if a loading error occurred.touch(): Updates the cache entry's touch time.resize(width, height): Resizes the bitmap.blt(source, sx, sy, sw, sh, dx, dy, dw, dh): Block transfer (draws part of another bitmap).bltImage(...): Likeblt, but assumes the source image is unmodified.getPixel(x, y): Gets the color of a pixel.getAlphaPixel(x, y): Gets the alpha value of a pixel.clearRect(x, y, width, height): Clears a rectangular area.clear(): Clears the entire bitmap.fillRect(x, y, width, height, color): Fills a rectangle with color.fillAll(color): Fills the entire bitmap with color.gradientFillRect(...): Fills a rectangle with a gradient.drawCircle(x, y, radius, color): Draws a circle.drawText(text, x, y, maxWidth, lineHeight, align): Draws text with an outline.measureTextWidth(text): Measures the width of text.adjustTone(r, g, b): Adjusts the color tone.rotateHue(offset): Rotates the hue.blur(): Applies a blur effect.addLoadListener(listener): Adds a listener for when the bitmap loads.decode(): Triggers the decoding/processing of the loaded image data.checkDirty(): Updates the underlying texture if the bitmap has changed.request(url): Creates a Bitmap in a 'pending' state for later loading.isRequestOnly(): Checks if the bitmap was created viarequest()and hasn't started decoding.isRequestReady(): Checks if the bitmap request has completed (or failed).startRequest(): Starts loading for a 'pending' bitmap.
- Loading States:
Graphics: Static class for managing the game screen, rendering, and related functionalities.- Properties:
width,height,boxWidth,boxHeight,scale,frameCount. - Blend Modes:
BLEND_NORMAL,BLEND_ADD,BLEND_MULTIPLY,BLEND_SCREEN. - Methods:
initialize(width, height, type): Initializes the graphics system.tickStart(),tickEnd(): Frame timing methods for FPS meter.render(stage): Renders the main stage.isWebGL(): Checks if the current renderer is WebGL.hasWebGL(): Checks if the browser supports WebGL.canUseDifferenceBlend(),canUseSaturationBlend(): Checks for canvas blend mode support.setLoadingImage(src): Sets the image used for the loading screen.startLoading(),updateLoading(),endLoading(): Manage the loading screen display.printLoadingError(url),eraseLoadingError(): Display/hide loading errors.printError(name, message): Displays a general error message.showFps(),hideFps(): Control FPS meter visibility.loadFont(name, url): Loads a font file.isFontLoaded(name): Checks if a font is loaded.playVideo(src),isVideoPlaying(),canPlayVideoType(type),setVideoVolume(value): Video playback methods.pageToCanvasX(x),pageToCanvasY(y): Convert page coordinates to canvas coordinates.isInsideCanvas(x, y): Checks if coordinates are within the canvas.callGC(): Calls the PIXI garbage collector.
- Properties:
Input: Static class for keyboard and gamepad input.- Properties:
keyRepeatWait,keyRepeatInterval,keyMapper,gamepadMapper,dir4,dir8,date. - Methods:
initialize(): Initializes the input system.clear(): Clears all input states.update(): Updates input states for the current frame.isPressed(keyName): Checks if a key is currently held down.isTriggered(keyName): Checks if a key was just pressed.isRepeated(keyName): Checks if a key was just pressed or is repeating.isLongPressed(keyName): Checks if a key has been held down for a while.
- Properties:
TouchInput: Static class for mouse and touchscreen input.- Properties:
keyRepeatWait,keyRepeatInterval,wheelX,wheelY,x,y,date. - Methods:
initialize(): Initializes the touch system.clear(): Clears all touch states.update(): Updates touch states for the current frame.isPressed(): Checks if the screen/left mouse button is pressed.isTriggered(): Checks if the screen/left mouse button was just touched/clicked.isRepeated(): Checks for trigger or pseudo-repeat.isLongPressed(): Checks if the screen/left mouse button is held down.isCancelled(): Checks if the right mouse button was just clicked.isMoved(): Checks if the mouse/touch position moved.isReleased(): Checks if the screen/left mouse button was just released.
- Properties:
Sprite(bitmap): Basic display object for images (inherits fromPIXI.Sprite).- Properties:
bitmap,width,height,opacity. - Methods:
update(): Updates the sprite and its children.move(x, y): Sets x and y position.setFrame(x, y, width, height): Defines the portion of the bitmap to display.getBlendColor(),setBlendColor(color): Manage blend color.getColorTone(),setColorTone(tone): Manage color tone.
- Properties:
Tilemap(): Displays a 2D tile-based map (uses canvas fallback).ShaderTilemap(): Displays a 2D tile-based map using WebGL shaders (preferred renderer).- Properties:
bitmaps,origin,flags,animationCount,horizontalWrap,verticalWrap,width,height,tileWidth,tileHeight. - Methods:
setData(width, height, data): Sets the map data.isReady(): Checks if all tileset bitmaps are loaded.update(): Updates animations.refresh(): Marks the tilemap for a full repaint.refreshTileset(): Updates the internal tileset textures (ShaderTilemap only).- Tile ID Checkers: Static methods like
isVisibleTile,isAutotile,isWaterTile, etc., to check tile properties based on their ID.
- Properties:
TilingSprite(bitmap): Sprite that repeats its image (inherits fromPIXI.extras.PictureTilingSprite).- Properties:
bitmap,opacity,origin. - Methods:
update(),move(x, y, width, height),setFrame(x, y, width, height).
- Properties:
ScreenSprite(): A simple container covering the screen, primarily used for screen color effects.- Properties:
opacity. - Methods:
setBlack(),setWhite(),setColor(r, g, b).
- Properties:
Window(): Base class for game windows (inherits fromPIXI.Container).- Properties:
windowskin,contents,width,height,padding,margin,opacity,backOpacity,contentsOpacity,openness,origin,active,downArrowVisible,upArrowVisible,pause. - Methods:
update(): Updates animations and children.move(x, y, width, height): Sets position and dimensions.isOpen(),isClosed(): Check openness state.setCursorRect(x, y, width, height): Defines the cursor rectangle.setTone(r, g, b): Sets the background color tone.addChildToBack(child): Adds a child behind the contents but above the background.
- Properties:
WindowLayer(): Container specifically for holdingWindowobjects, managing rendering order and masking (inherits fromPIXI.Container).Weather(): Handles weather effects (rain, storm, snow) (inherits fromPIXI.Container).- Properties:
type,power,origin. - Methods:
update().
- Properties:
ToneFilter(): WebGL filter for color tone adjustments (inherits fromPIXI.filters.ColorMatrixFilter).ToneSprite(): Fallback for tone changes in Canvas mode (inherits fromPIXI.Container).Stage(): The root display object (inherits fromPIXI.Container).
WebAudio(url): Handles audio playback using the Web Audio API.- Static Methods:
initialize(noAudio),canPlayOgg(),canPlayM4a(),setMasterVolume(value). - Properties:
url,volume,pitch,pan. - Methods:
clear(),isReady(),isError(),isPlaying(),play(loop, offset),stop(),fadeIn(duration),fadeOut(duration),seek(),addLoadListener(listener),addStopListener(listener).
- Static Methods:
Html5Audio: Static class handling audio playback using the HTML5<audio>element (fallback).- Static Methods:
setup(url),initialize(),setStaticSe(url),clear(),isReady(),isError(),isPlaying(),play(loop, offset),stop(),fadeIn(duration),fadeOut(duration),seek(),addLoadListener(listener). - Properties:
url,volume.
- Static Methods:
JsonEx: Static class for serializing and deserializing JavaScript objects with prototype information and handling circular references.- Methods:
stringify(object),parse(json),makeDeepCopy(object).
- Methods:
Decrypter: Static class for handling encrypted game assets.- Properties:
hasEncryptedImages,hasEncryptedAudio. - Methods:
checkImgIgnore(url),decryptImg(url, bitmap),decryptHTML5Audio(url, bgm, pos),decryptArrayBuffer(arrayBuffer),createBlobUrl(arrayBuffer),extToEncryptExt(url).
- Properties:
ResourceHandler: Static class to manage retrying failed resource loads.- Methods:
createLoader(url, retryMethod, resignMethod, retryInterval),exists(),retry().
- Methods: