if (!freeCoordinates) {
let x = 0;
let y = 0;
switch(location) {
case 'rightBottom':
x = Graphics.width - (iconWidth + iconMarginLeft + iconMarginRight);
y = Graphics.height - (iconHeight + iconMarginTop + iconMarginBottom);
break;
case 'leftBottom':
x = iconMarginLeft + iconMarginRight;
y = Graphics.height - (iconHeight + iconMarginTop + iconMarginBottom);
break;
case 'rightTop':
x = iconMarginLeft + iconMarginRight;
y = iconMarginTop + iconMarginBottom;
break;
case 'leftTop':
x = Graphics.width - (iconWidth + iconMarginLeft + iconMarginRight);
y = iconMarginTop + iconMarginBottom;
break;
default:
break;
}
作者: xuhao1996 时间: 2021-9-9 03:13
[fold=原版代码IconButton.js]'use strict';
/* global PIXI */
/* global Bitmap */
/* global PluginManager */
/* global ImageManager */
/* global SceneManager */
/* global Graphics */
/* global Scene_Map */
/* global Sprite */
/* global TouchInput */
/* global $gameTemp */
/* global Window_Message */
//=============================================================================
// IconButton.js
//=============================================================================
/*:
* @target MZ
* @plugindesc IconButton plugin.
* @author BananaPepperTK
*
* @help Turn the system icon into a button.
*
* For more information
* https://github.com/sevenspice/IconButton
*
* @param FreeCoordinates
* @desc How to specify the position of icons. If it is true, specify the display position directly by command.
* @default false
*
* @param IconSet
* @desc The name of the sprite sheet for the icon set to be used. If nothing is specified, the default icon set will be used.
*
* @param IconSize
* @desc The number of pixels per side of the icon in the spritesheet.
* @default 32
*
* @param IconCount
* @desc The maximum number of horizontal rows of icons in the spritesheet.
* @default 16
*
* @param IconMarginLeft
* @desc Left margin of the icon.
* @default 10
*
* @param IconMarginRight
* @desc Right margin of the icon.。
* @default 10
*
* @param IconMarginTop
* @desc Top margin of the icon.
* @default 10
*
* @param IconMarginBottom
* @desc Bottom margin of the icon.
* @default 10
*
* @command create
* @text create
* @desc Generate icon.
*
* @arg id
* @type number
* @text ButtonID
* @desc ID value that identifies the button.
*
* @arg eventId
* @type common_event
* @text CommonEventID
* @desc The common event ID to be executed.
*
* @arg iconId
* @type number
* @text IconID
* @desc The ID of the icon to be displayed.
*
* @arg location
* @type string
* @default rightBottom
* @text location
* @desc Place it somewhere in the four corners of the screen. leftTop or leftBottom or rightTop or rightBottom
*
* @arg x
* @type number
* @default 0
* @text x-coordinate
* @desc Direct designation.
*
* @arg y
* @type number
* @default 0
* @text y-coordinate
* @desc Direct designation.
*
* @arg scale
* @type number
* @default 1.0
* @text Rate of expansion and contraction
* @desc Zoom in/out ratio of the displayed icon.
*
* @arg text
* @type string
* @text text
* @desc The text to be displayed at the bottom of the icon.
*
* @arg fontSize
* @type number
* @default 14
* @text fontsize
* @desc Font size of the text to be displayed at the bottom of the icon.
*
* @command show
* @text show
* @desc Show icon.
*
* @arg id
* @type number
* @text ButtonID
* @desc ID value that identifies the button.
*
* @command update
* @text update
* @desc Update icon.
*
* @arg id
* @type number
* @text ButtonID
* @desc ID value that identifies the button.
*
* @arg x
* @type number
* @default 0
* @text x-coordinate
* @desc Direct designation.
*
* @arg y
* @type number
* @default 0
* @text y-coordinate
* @desc Direct designation.
*
* @arg scale
* @type number
* @default 1.0
* @text Rate of expansion and contraction
* @desc Zoom in/out ratio of the displayed icon.
*
* @arg text
* @type string
* @text text
* @desc The text to be displayed at the bottom of the icon.
*
* @arg fontSize
* @type number
* @default 14
* @text fontsize
* @desc Font size of the text to be displayed at the bottom of the icon.
*
* @command hide
* @text hide
* @desc Hide icon。
*
* @arg id
* @type number
* @text ButtonID
* @desc ID value that identifies the button.
*
*/