Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: Sprite Moving with Character
- Original author: sayus2884
- Original date: August 22, 2019
- Source thread: https://forums.rpgmakerweb.com/threads/sprite-moving-with-character.112451/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Learning Javascript
Summary
Hi. So I'm able to add a sprite into the Scene_Map. However, the sprite moves with the character relative to its x and y on the screen. How do I make it so it just stays in the specified position? Spoiler: Moving with Character { "lightbox_close": "Close",
Archived First Post
Hi. So I'm able to add a sprite into the Scene_Map. However, the sprite moves with the character relative to its x and y on the screen. How do I make it so it just stays in the specified position?
Here is the code for my sprite
Then I used this.addChild() from the Scene_Map class to add the sprite into the map.
Protected download
Protected download
Protected download
Here is the code for my sprite
Code:
Sprite_ItemIcons.prototype = Object.create(Sprite.prototype);
Sprite_ItemIcons.prototype.constructor = Sprite_ItemIcons;
Sprite_ItemIcons.prototype.initialize = function(item = {}, event){
Sprite.prototype.initialize.call(this);
this._item = item;
this._event = event;
this.createIcon();
this.refreshIcon();
}
Sprite_ItemIcons.prototype.createIcon = function() {
this._iconBitmap = ImageManager.loadSystem('IconSet');
this._icon = new Sprite(this._iconBitmap);
var x = this._event.screenX() - 16;
var y = this._event.screenY() - 40;
this.setTransform(x,y);
this.addChild(this._icon);
}
Sprite_ItemIcons.prototype.refreshIcon = function() {
var w = Window_Base._iconWidth;
var h = Window_Base._iconHeight;
var iconindex = this._item.iconIndex;
var sx = iconindex % 16 * w;
var sy = Math.floor(iconindex / 16) * h;
this._icon.setFrame(sx,sy,w,h);
}
Then I used this.addChild() from the Scene_Map class to add the sprite into the map.
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadReferenced Images / Attachments
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...

