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
158
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
37,983
Reaction score
10,551
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,206
Reaction score
874
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,206
Reaction score
874
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

Vegan post. Pic of a pig in a suit and tie like he is laying in a coffin but it's a sandwich. 'One meal soon forgotten, in exchange for a whole life." Really don't think rolling around in poop your whole life would be so valuable.
Guys, Tutorials is for posting tutorials you have written, not for asking for help. Use the Support forums for that please.
Trailer is almost done for the game i can't wait to show it to everyone
I've got good news and bad news. The good news is, there aren't any bad news to report. The bad news is, there aren't any good news to report.

Or as others say, yesterday was uneventful.


I am curious that can you "understand/get the point" about what does this place do generally?
(ARPG game)

Forum statistics

Threads
129,860
Messages
1,205,769
Members
171,038
Latest member
WickedValentinez
Top