Rainy Pride Games [RPG]

Principiant Scripter
Member
Joined
Jan 14, 2015
Messages
16
Reaction score
1
First Language
Spanish
Primarily Uses
Hi guys, when I want to show a picture in a scene's script this wild error appears:


Sin título.jpg


this is the script to show it:

Code:
  def create_credits_image
    screen.pictures[1].show(OCEANCREDITS::CREDITSIMAGE, 1, 0, 0, 0, 0, 100, 0)
  end



What am I doing wrong?
 
Last edited by a moderator:

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
157
First Language
English
Primarily Uses
RMXP
Well, if the 'pictures' value is the array within the Game_Screen class, you, then we have a decipherable problem.


You have some value called 'screen', in your 'screen.pictures[1]' code.  If this was meant to be the pictures array in Game_Screen, you would instead use ...


$game_screen.pictures[1]...


This would make since with RMXP, VX and VXAce.  Same basic Game_Screen class, though coded slightly differently, and both the Game_Map and Game_Troop classes access the Game_Screen class with...


@screen = Game_Screen.new


Note the '@' to make make the @screen value which can be accessed throughout that particular class.


But if 'screen' is not meant to reflect the Game_Screen class, more of your script may be needed.
 
Last edited by a moderator:

Rainy Pride Games [RPG]

Principiant Scripter
Member
Joined
Jan 14, 2015
Messages
16
Reaction score
1
First Language
Spanish
Primarily Uses
It worked but now appears this


Sin título2.jpg


this is all picture's script

Code:
#==============================================================================#
#     * Create Credits                                                         #
#==============================================================================#
  def create_credits_image
    @screen = Game_Screen.new
    $game_screen.pictures[1].show(OCEANCREDITS::CREDITSIMAGE, 1, 0, 0, 0, 0, 100, 0)
  end
#==============================================================================#
#     * Move Credits                                                           #
#==============================================================================#
  def move_credits
    $game_screen.pictures[1].move(0, 0, -Height, 0, 0, 100, 0, 5400)
  end
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
35,817
Reaction score
9,473
First Language
German
Primarily Uses
RMMV
when and where are those commands executed?


That error basically says that the data doesn't exist (yet).


This can either happen if you didn't start a new game or if the command is called at a time before the data is defined.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,201
Reaction score
858
First Language
Hungarian
Primarily Uses
RMVXA
If you are making a new scene, forget about event commands, even if they are "translated" to scripts. They won't work on most scenes anyway.


You should not use them in new, custom scenes, only on the map scene and other map related things, and only if you really need them, which is rare, actually.


If you want to show a picture, use a simple sprite, and assign your image as a bitmap for it. 


It should look something like this:

@pic = Sprite.new
@pic.bitmap = Cache.picture("MyPicNameHere")
@pic.x = 100
@pic.y = 0



This is how you create images on the game's screen in any scene.


But all sprites must be disposed correctly upon leaving the scene, that is mandatory.


You can do that this way:

@pic.bitmap.dispose
@pic.dispose



First, you dispose the bitmap, than the sprite itself. You should call this either in the scene class' 'terminate' or 'dispose_all_windows' method.


To move around the image, you can alter it's Y position in the 'update' method of the scene class. Just make your conditions (when to start, where to stop, etc) and based on those, move your image how you like.


For example:

def update
super
# If the image is visible on the screen, move the image upwards
if @pic.y > -@pic.bitmap.height
@pic.y -= 1 # 1 is the speed of the movement
end
end

This example will scroll the image upwards until it gets out of screen completely. It assumes that the starting Y position was 0 (top of the screen) for the sprite.


I just assumed that you want to make a scrolling credit list (judging by your script and method names), that's why I wrote these examples.


Based on what other things you want to do on that scene, you will need to add other code-bits obviously. I recommend you to search for some tutorials on how to manipulate sprites in Ruby. Once you learn that, working with images will be as easy as hitting the bed at the end of the day. 
 

Rainy Pride Games [RPG]

Principiant Scripter
Member
Joined
Jan 14, 2015
Messages
16
Reaction score
1
First Language
Spanish
Primarily Uses
Thanks Sixth it worked! thanks for all.


I will read the tutorials.
 

Rainy Pride Games [RPG]

Principiant Scripter
Member
Joined
Jan 14, 2015
Messages
16
Reaction score
1
First Language
Spanish
Primarily Uses
Now this is the problem now appears "undefinied method 'bitmap' for nil:NilClass" when I want to change the scene when the players use :C button


Sin título3.jpg


And this is line 85

Sin título4.jpg
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,201
Reaction score
858
First Language
Hungarian
Primarily Uses
RMVXA
@sprite is not defined. 


If you got no such instance variable which is a sprite, you can't really dispose it's bitmap (or itself), right?


If you do have a sprite named like that, but it is initialized at a later point, just add a condition to that method which checks if there is a @sprite variable or not before doing something with it.


You can do that with a simple "if @sprite" check. 


It might help if we could see the whole script. Guessing the source of the error is often more time consuming than it should be.
 

Latest Threads

Latest Posts

Latest Profile Posts

I'm working with Excel today, and I just hate VBA so much. It's like the designers said "How can we make a programming language that works as obtusely and inefficiently as possible?"
Beep-Beep-Motha-facka.gif

Just finished and uploaded the delivery truck base/sprite sheet. I've been steadily replacing the default assets with early modern alternatives. The air-ship for a biplane, horse-drawn wagon for a delivery truck, and next a sailboat for a steam-powered passenger liner (think of the SS Olympic and RMS Titanic).
I caught a shiny magikarp on pokemonGO today AND finally saw Detective Pikachu and it was so cute and I'm still so hype AHHHHH!!!
one of the coolest things I've learned from the forums is the ability to give yourself a hitbox. I have a move you can do on the fields. shoulder tackle. thanks to the forums, that tackle triggers self A switches on some events. NPC's and the environment now react to the tackle. awesome.
I really liked how this one turned out! :kaopride:
WYqMPf6.png

Character (Yes, this is a character): Nibiru the Primal Being from Yugioh.

Forum statistics

Threads
121,946
Messages
1,145,368
Members
160,220
Latest member
Trex1930
Top