RPGMAKER game engine is based on JavaScript plug-in production (Appendix 1) - Elf class (sprite) properties, methods and interpretation of the whole prototype chain

Elves, placed in the scene or window, a bitmap created by, can show an animated object.
This article describes the wizard class properties, methods, and the relationship between RM prototype chain comes elves According to my experience, combined with RPGMAKER MV JS library to provide information, as well as their understanding of the game source code written rpg_sprites.js

Window object and the scene is a wizard container, may be added by the wizard function addChild, the same time as a container for other sprite sprite object, tutorial six see


1. The Wizard of property

About positions:
Anchor: number of 0-1, is to set the sprite drawing start coordinate, a relative position adjustment sprite properties, often with the move function uses
rotation: number, the rotation angle of the sprite
x, y: Number , X sprite coordinates, Y coordinates, the coordinates can not exceed the framework of attention, and often move method with the use of methods and setFrame

Elf on the image itself:
Bitmap: Bitmap file PNG
Scale: number, scaling wizard, commonly used in the design of the effect of clicking buttons, sometimes inappropriate images for pixel scaling (can be edited directly with Microsoft's own Sketchpad tool picture pixels)
height, width: the number of pixels high and wide, elves image
opacity: 0-255 number, elves opacity
visible: Boolean value, whether visible wizard

About Prototype relationship:
Children: array, read-only attribute, the sub-current sprite sprite contained
parent: the array, read-only attribute contains the current parent container wizard

Is not clear:
the blendMode: digital, sprite image compositing mode, the current will not use
filters: array, the wizard to the filter, not by the current

2. The method wizard

Management subclasses:
the addChild: parameter object, the role of the container is added to an object, the object becomes a child added spirit
addChildAt: parameter object and number, is added to the container to a target position. This object is obtained by the children array specify this attribute
removeChild: parameter object, the container of a sub-current sprite removed
removeChildAt (index): By removing Elf parameter index, used in conjunction with addChildAt

Color Management:
getBlendColor: return value is an array of r, g, b, a, to obtain the current sprite color mixing
getColorTone: return value is an array of r, g, b, gray, obtain the current sprite tone
setBlendColor (color): parameter array provided sprite mixed color
setBlendTone (color): parameter array, disposed sprite color

Management positions:
Move (X, Y): X, Y is the number of pixels based on the initial positional displacement, the coordinate system defaults to the upper left corner of the right-handed coordinate system as the starting point, can be changed by providing the take-based anchor starting
setFrame (x, y, width, height): set a sprite rectangle area movable range, XY coordinates of the upper left corner area, in pixels, that is to say its spirit and its own sub wizard can not exceed the rectangular area, note that the positive direction of the XY here seems to be and the positive direction of the move is the opposite

Control the animation:
Update (): Refresh function, by default called once every frame refresh, if you want to refresh less frequently (saving computing resources or implement special functions), you can set a cumulative variable and judgment statements made in this function in then refresh it from time to time.

3. Elf prototype chain relationships

Pro-finishing most detailed maps


Say one more thing, I just assist these reference tools, you want to really learn to learn deep 3 must study the source code, and more practice!
Finishing is not easy, but also look thumbs up.
Here Insert Picture Description

Published 12 original articles · won praise 36 · views 3329

Guess you like

Origin blog.csdn.net/xmoss/article/details/104990680