ZACHARY_BRAUN'S PROFILE

I'm a webcomic author. One of my webcomic stories is going to be in the form of an RPG maker game.

Search

Filter

Creating a Sprite Array

Is it possible to create an array of sprite objects in Ruby?

I'm looking to do something like this:


$thespritemap = Array.new
$thespritemap.each {|x|, $my_sprite|x| = Sprite.new}

The important part is being able to refer to the sprite's object with a variable, like:


$thespritemap[2] # $my_sprite2
$thespritemap[2].bitmap = RPG::Cache.pictures('my_sprite_picture')

This is to avoid typing something like this out:


$my_sprite1 = Sprite.new
$my_sprite2 = Sprite.new
...
$my_sprite200 = Sprite.new

I couldn't find help for this in any Ruby documentation, so I don't know if I'm even approaching the solution to this correctly.

-------------------------------

Edit: Potentially solved. This seemed to work: Spoke too soon; seems like there's a problem with the name being a string.

$thespritemap = Array.new
num = 1
while num <= 20 do
name = '$my_sprite', num
$thespritemap << name
num += 1
end
$thespritemap.each {|x| x = Sprite.new}

What the above code does, is creates an array of 20 objects, called
"$my_sprite1"
"$my_sprite2"
"$my_sprite3" etc... up to "$my_sprite21". This looked good, and also threw no errors when each was supposedly converted into a Sprite object with "Sprite.new", but on attempting to refer to them, they only seem to be strings that look like variables, not actual referrable objects that variables are supposed to be.

Calling a Script like a Common Event

Thanks again for all the advice.

I have another question... Regarding the two following commands:

MyClass.new.MyMethod

$My_object = MyClass.new
$My_object.MyMethod

These two appear to be the same, but what happens when you don't name an object, like in the first example? Does it just float around somewhere until it's garbage-collected?

[rm2k3] Custom Fonts

Oh... that's true. Although with RPG Maker 2000/2003, I think every font has to be fixed-width, even the normal in-game one.

Calling a Script like a Common Event

I see... I was playing around with sprites and, similarly, found that new sprite objects are made in the same fashion: "@my_sprite = Sprite.new" then assigning a bitmap to that object. Oddly, those sprites seem to vanish after 3 seconds.

However, when I create a new $object out of that database code, it seems to stick around, like you say. Maybe that's the difference between the dollar sign and the @ sign: persistence. I'll experiment further.

Calling a Script like a Common Event

Thanks. I tinkered with it for a couple of days and found out that this involves typing out "(Name of Class here).new.(Name of 'def' here)". But if it's as simple as typing out the "def" name (what I assume is really called a Method) then that's even easier.

What I'm concerned with now, is, if this is a new object, should I be destroying it somehow in order to keep them from piling up?

Calling a Script like a Common Event

Hello all,

In my RPG Maker 2003 project, I have common event upon common event of variable settings. These common events act like custom-built databases. They do their job, but now that I am experimenting with RPG Maker XP, I realized that these databases can now be typed out into a script in the Script Editor, saving a lot of space and facilitating editing (not to mention a powerful search feature).

What I would like to know is, how to call a script like one would call a common event.

I would set my initial arguments for what I need the database to look up, call the script acting as a database, and then have all of my appropriate variables set.

The only thing I know is that this would be done from the "Script..." menu command. Where to go from there?

[rm2k3] Custom Fonts

Come to think of it... You could already do that by replacing the special characters bitmap with a font. You would simply have to enter in all your text $l$i$k$e $t$h$i$s.

[RM2K3 DynRPG] Fog of War Request

Try this tutorial: http://rpgmaker.net/tutorials/479/

It was mentioned in a few topics below this one: a request for something to help with line of sight.

I don't understand it very well myself, but it seems to allow for the function of what you want.

RM2k3 CustomSaveLoadPatch: Create your own save/load system!

Hi Cherry,

I have an important question about these patches. Will they work with save files that we've already created with the default save/load system?

Thank you again,
Zack

[RM2k3] Borders for randomly-moving touch encounter monster events

Is it also possible to create an event-only barrier using the "Allow Event Overlap" checkbox?