CuddleFox

Furry
Veteran
Joined
Feb 18, 2017
Messages
128
Reaction score
43
First Language
French
Primarily Uses
RMVXA
Hello,
I searched and I didn't find a topic related to this.
I would like to know if there is a way to move an enemy battler in the same way that you could move an image, by just manipulating its x and y?
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
600
First Language
Italian
Primarily Uses
RMVXA
A way to do that exists, but how you can do it depends a lot on when you want to do it. You can do it with a script call as well, but I am not sure I would recommend it. The implementation depends a lot on what you exactly need. Could you be more specific?
 

CuddleFox

Furry
Veteran
Joined
Feb 18, 2017
Messages
128
Reaction score
43
First Language
French
Primarily Uses
RMVXA
I need a battler to go to the right, Out of the screen.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
600
First Language
Italian
Primarily Uses
RMVXA
If you know what battler you are talking about (as in troop id of that battler) you can get it from the scene itself.
Code:
spriteset = SceneManager.scene.instance_variable_get(:@spriteset)
enemies = spriteset.instance_variable_get(:@enemy_sprites)
Once you do that, you have every enemy sprite in your troop stored inside "enemies". You can access the N element of that array using
Code:
enemies[N] # N is the ID of your battler in the troop array

Moving ti is just as moving a normal sprite with x and y coordinates. If you want it to move to the right side you increase its X coordinate, if you want it to move down you increase its Y coordinate (decrease those coordinates if you want to move it respectively toward the left side or up).

All this can be placed in a single script call in an event with a small loop taking care of the movement itself.
Code:
# shift a sprite to right side
ppf = 4 # pixels per frame
spr_id = 3 # id of the enemy in the troop array
spriteset = SceneManager.scene.instance_variable_get(:@spriteset)
enemies = spriteset.instance_variable_get(:@enemy_sprites)
spr = enemies[spr_id]
while ((spr.x - spr.ox) < Graphics.width)
  spr.x += ppf
  Fiber.yield
end
 

Latest Threads

Latest Posts

Latest Profile Posts

BGM playlist:

(It does not work with an open menu, as it affects events in parallel process)
sorry I've been quiet for like-- ever - A -) been dealing with constant family/personal issues. Got a wisdom tooth out today though! one less thing to deal with
Definetly a WIP but having fun with those desert tiles xD

Forum statistics

Threads
111,248
Messages
1,059,573
Members
144,519
Latest member
ThatGuyWheels
Top