I'm trying to code here, looking at rpg_objects stateIcons, rpg_windows drawIcon, and rpg_sprites Sprite_StateIcon..
here is the body code
here is the create function:
Right now.. this is what it looks like.. its the whole "iconset" loaded and not trimmed!
this is how it should look like..
here is the body code
JavaScript:
//-----------------------------------------------------------------------------
// Sprite_AttackIcon
//
function Sprite_AttackIconSprite() {
this.initialize.apply(this, arguments);
}
Sprite_AttackIconSprite.prototype = Object.create(Sprite.prototype);
Sprite_AttackIconSprite.prototype.constructor = Sprite_AttackIconSprite;
Sprite_AttackIconSprite.prototype.initialize = function(character) {
Sprite.prototype.initialize.call(this);
//this._iconIndex = 0;
this.loadBitmap();
this.x = -34;
this.y = -40;
this.z = 9;
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.scale.x = 0.5;
this.scale.y = 0.5;
};
Sprite_AttackIconSprite._iconWidth = 32;
Sprite_AttackIconSprite._iconHeight = 32;
Sprite_AttackIconSprite.prototype.loadBitmap = function() {
this.bitmap = ImageManager.loadSystem('IconSet');
//this.setFrame(0, 0, 0, 0);
};
Sprite_AttackIconSprite.prototype.setBattler = function(battler) {
if (this._battler === battler) return;
this._battler = battler;
};
// assign icon index here
Sprite_AttackIconSprite.prototype.update = function() {
Sprite.prototype.update.call(this);
if (this._iconIndex) {
this.updateIcon();
this.updateFrame();
this.refresh();
}
};
Sprite_AttackIconSprite.prototype.updateIcon = function() {
if (!this._battler || this._battler.isActor()) {
this._iconIndex = this._battler.weapons()[0].iconIndex; // actor
} else {
this._iconIndex = $dataWeapons[Number(this._battler.enemy().meta.srpgWeapon)].iconIndex; // enemy
}
};
Sprite_AttackIconSprite.prototype.updateFrame = function() {
var pw = 32;
var ph = 32;
var sx = 101 % 16 * pw;
var sy = Math.floor(101 / 16) * ph;
this.setFrame(sx, sy, pw, ph);
};
// draw the icon text here
Sprite_AttackIconSprite.prototype.refresh = function() {
this.bitmap.clear();
if (this._iconIndex === 0) return;
//var pw = Sprite_AttackIconSprite._iconWidth;
//var ph = Sprite_AttackIconSprite._iconHeight;
//var sx = this._iconIndex % 16 * pw;
//var sy = Math.floor(this._iconIndex / 16) * ph;
this.bitmap.blt(this.bitmap, sx, sy, pw, ph, x, y);
};
here is the create function:
JavaScript:
Sprite_Character.prototype.createAttackIconSprite = function() {
if (!this._AttackIconSprite) {
this._AttackIconSprite = new Sprite_AttackIconSprite();
var battler = $gameSystem.EventToUnit(this._character.eventId())[1];
this._AttackIconSprite.setBattler(battler);
this.addChild(this._AttackIconSprite);
}
};
Right now.. this is what it looks like.. its the whole "iconset" loaded and not trimmed!
this is how it should look like..