Moving an enemy's battler

CuddleFox

Furry
Veteran
Joined
Feb 18, 2017
Messages
116
Reaction score
40
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
596
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
116
Reaction score
40
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
596
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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,038
Members
137,567
Latest member
sashalag
Top