Jump to content


Photo

Picture Wrapper


  • Please log in to reply
45 replies to this topic

#1 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 30 April 2012 - 02:42 AM

Picture Wrapper
v1.2
Tsukihime

Introduction

There must be an easier way to work with picture objects.

This script extends the Game_Picture class with additional methods that manipulate the picture object, and exposes a set of functions to the Game Interpreter..

Features

-change picture by name. Supports any string formatting including variable assignment
-move picture by absolute coords (relative to screen)
-move picture by relative coords (relative to image origin)
-zoom picture
-rotate picture
-fade-in/fade-out
-spin picture around origin or top-left corner (in-progress...)
-change the tone
-change the blend type
-horizontal flip
-vertical flip
-toggle grayscale

You can combine any call together as well.

Usage

Copy into script editor.
Call the functions through script or script box
Make sure that a picture with the specified filename exists in your Graphics Pictures folder.
Examples at the top of the file

Example

Show a picture with name "test_pic" at coords (10, 10) with opacity 255

make_pic("test_pic", 255, 10, 10)
Shift the picture to the left 20 units along the x-axis over a duration of 60 frames

shift_pic(-10, 0, 60)
Make a second picture with name "pic2" at coords(60, 10) with opacity 255)

make_pic("pic2", 255, 60, 10, 2)
Note that spin_pic(0) stops your picture from spinning.

Script

Link: Download here

Known issues

*You should make sure you have a valid picture on the screen before you call the picture manipulation methods.
*bitmap appears to be mysterious disposed when you change scenes even though picture is still on the screen
*picture is still on the screen even if you switch maps.

Notes

When it says "wait" it means the whole game waits while the action is being processed.
I'm going to look into changing this to support two types of waits:

-whole game waits
-next event waits

Which makes more sense.

If you want something added just ask. I'm just adding wrappers based on order of difficulty.
May be updated at anytime when I find more ways to work with Picture objects.

Edited by Tsukihime, 14 June 2016 - 11:58 AM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#2 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 30 April 2012 - 02:17 PM

Script has been updated with some more amusing functions.

*shift_pic - moves the picture over, relative to the current x,y coords.
*spin_pic - now you can choose to spin relative to the center of the image, or the top-left corner of the image. Not perfect though...

I am not too sure about my design though.
I basically fetch a copy of the bitmap from cache in order to have easy access to the width and height attributes.

I need those values in order to be able to spin the image on the spot.

Edited by Tsukihime, 30 April 2012 - 02:26 PM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#3 Chaos17

Chaos17

    Advanced Member

  • Member
  • 344 posts
  • RM Skill - Jack of All Trades

Posted 01 May 2012 - 07:57 AM

Can you give an example, please ?
Because I would like to use your script for changing the skin of the default menu.
Is it possible ? If yes, I would like to know how to do it.

ban.png


#4 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 01 May 2012 - 03:28 PM

Windowskins are controlled by the Window_Base class, so it is not related to the Game Picture class.

I've posted a topic here discussing window skin changing via script calls. I would imagine that a larger "configuration" script already has window skin changing support but I don't know what they might be.

Edited by Tsukihime, 01 May 2012 - 03:29 PM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#5 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 02 May 2012 - 06:27 PM

I've added "wait for completion" functionality so you can chain a bunch of commands together.

spin_pic(30)
move_pic(0, 0, 60, true)

would allow you to spin your picture while it's moving to the target coords.

Also note that spin_pic(0) turns off spinning, if you're wondering how to stop your image from spinning.

Note that not every method has a "wait" function because it doesn't really make sense for pictures that don't take effect over a period of time to have a wait option.

I have tried to implement a very simple "animation" features where it assumes your pictures are stored like

image001
image002
image003
...
image012
...

But it is TOO slow since they are not cached apparently. So I have not included it.
Maybe if I find a better way to do it.

I've also generalized it so you can draw a picture in a battle as well.
The problem is that you could in theory want to draw a picture anywhere (through script calls from the script editor) but I haven't seen anything that requires that.

Edited by Tsukihime, 02 May 2012 - 08:07 PM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#6 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 05 May 2012 - 06:03 PM

Added four new methods

  • grayscale_pic: toggles grayscale
  • mirror_pic: toggles horizontal flip
  • flip_pic: toggles vertical flip
  • spin_pic: toggles spinning on and off (corrected from before)

When I say horizontal flip, it means I'm flipping it along y-axis, relative the center of the image. Similarly, vertical flip is along x-axis. It is not the same rotating 180 degrees.

Spinning has also been implemented correctly. Now you can toggle spinning on and off.
All operations can be combined together.

I rewrote the library by moving all of the picture indices to the first argument. Turns out the index is used more often than all the other parameters after I took this picture lol.

Posted Image

Posted Image

Edited by Tsukihime, 05 May 2012 - 07:37 PM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#7 Henry

Henry

    Newbie

  • Member
  • 4 posts

Posted 24 May 2012 - 01:40 PM

Thank you for your script, Tsukihime. :)

I've some questions, being a beginner in RGSS: must I paste the whole script in a new page in RGSS3 script-list or
must I paste its methods in their respective class?

#8 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 24 May 2012 - 02:34 PM

Just paste in a new page.
All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#9 Henry

Henry

    Newbie

  • Member
  • 4 posts

Posted 24 May 2012 - 02:54 PM

Thanks for you answer!
I've just did that, however the game returns a script error.

Which class must I call to display a picture with your script? I tried Game_Picture
(with @image = Game_Picture.new) but that doesn't remove the error.

Could you help me out?

#10 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 24 May 2012 - 03:04 PM

What are you trying to do?

These are meant for event script boxes. I've probably sample calls in the first post.
All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#11 Henry

Henry

    Newbie

  • Member
  • 4 posts

Posted 24 May 2012 - 03:09 PM

Actually, I'm trying to use these methods in a script in the script editor.

Edited by Henry, 24 May 2012 - 03:11 PM.


#12 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 24 May 2012 - 04:50 PM

I haven't written any scripts using these methods.
You would need to create a picture sprite and assign it a specific Game_Picture.


image = Game_Picture.new
sprite = Sprite_Picture.new

#somehow assign the image to the sprite

image.show_pic(...)

And then you need to make sure the sprite is getting updated.
It is not simple.
All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#13 Henry

Henry

    Newbie

  • Member
  • 4 posts

Posted 24 May 2012 - 07:10 PM

Thanks!
Event commands are definitely simpler. B)

#14 stramin

stramin

    Advanced Member

  • Member
  • 37 posts

Posted 18 October 2012 - 08:41 PM

Hello Tsukihime!

I used your script to make a light effect, but I think doesn't have the feature what I need :(

I'm looking for a way to show map position relative pictures, not screen relative, so when the player walk the picture moves with the map (just like RPGMaker 2000)

Do you know a way to do it?

If its not possible, its a good idea for an update, don't you think?
Posted Image

#15 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 18 October 2012 - 09:13 PM

Pictures are drawn on the screen, and the screen is basically the camera.
I don't know how to draw pictures on the map directly..
All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#16 Galv

Galv

    Forum Defender

  • Staff Manager/Global Mod
  • 5609 posts
  • LocationAustralia
  • RM Skill - Jack of All Trades

Awards Bar:

Users Awards

Posted 18 October 2012 - 09:48 PM

I know of Modern Algebra's script that fixes images to the map if that helps
http://rmrk.net/inde...p?topic=39052.0

gs-banner_zpsfc59b073.pngp7GQmH4.png 2hjKrWv.png


#17 reLic

reLic

    Member

  • Member
  • 19 posts

Posted 19 October 2012 - 07:53 AM

Hi, Love your script and using it in my game. I recently started to add save points in my game and discovered that after displaying a picture using your script i wasn't able to save my game anymore. I looked in another thread http://www.rpgmakerv...-saving-glitch/ and noticed others have the same problem. However using his fix (Comment out code) didn't help for me.

Do you have any other ideas on how to fix this problem? Or could you show me some code on how to display a picture without using your script?

#18 stramin

stramin

    Advanced Member

  • Member
  • 37 posts

Posted 21 October 2012 - 07:34 PM

hey tsuki! I got it!




module FIX
  module UTILITY2
	FIX_PICTURE_SWITCH = 11
  end # UTILITY
end # FIX



module Switch2
  def self.fix_picture
	return $game_switches[FIX::UTILITY2::FIX_PICTURE_SWITCH]
  end
end # Switch

class Sprite_Picture < Sprite
  def update
		super
		if @picture.name != ""
			update_bitmap
			update_origin
			if Switch2.fix_picture or @picture.name.include?("[FIXED]")
			  self.x = 0 - $game_map.display_x * 32 + @picture.x
			  self.y = 0 - $game_map.display_y * 32 + @picture.y
			else
			  update_position
			end
			update_zoom
			update_other
		else
			self.bitmap.dispose if self.bitmap != nil
		end
  end
end


its a mix from 2 scripts (Seer UK and Yanfly Channel), when the switch 11 is on all the pictures are fixed, when the picture name contain "[FIXED]" that picture is fixed.

I think you could add this on your script, because your picture wrapper is the best picture script i ever seen... well the Yanfly Channel made a flip picture switch too, very useful

Edited by stramin, 21 October 2012 - 07:39 PM.

Posted Image

#19 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 21 October 2012 - 08:17 PM

I have added that snippet into the picture wrapper.
I have added the following function

fix_pic(index, bool)

If the picture is not fixed, it will become fixed.
You can pass in `false` for the bool if you want to un-fix it.

However, I have not worked out the coordinates when you change the fixed value so...you should avoid doing that.

Instead, you should specify the fixed value when you create the picture

make_pic(1, "name", opacity, x, y, origin, fixed)

Then the picture will appear in the correct spot, where x and y is the position in tiles.

Edited by Tsukihime, 21 October 2012 - 09:10 PM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#20 stramin

stramin

    Advanced Member

  • Member
  • 37 posts

Posted 21 October 2012 - 09:02 PM

I think is perfect in that way, you did it... (again), tsuki!
Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users