How do I Create Sprites

Essentially I'm looking to do the following.


Place an image on the screen


[Optional overlays]


Then dispose of it


I would also like to be able to call it via script


like so: imagescreen(path, [effects])


Thanks for any help!
Perhaps you should take more time to explain to us what you're trying to do, especially as you're mixing things that have nothing to to with each other.


The RM community has some specific references, and what you're describing in your text is placing a picture and has nothing to do with sprites, contrary to your title.


And why don't you simply use the show picture commands from the events? their functions can also be called from scripts, but we can't even see if you really need a script or couldn't do everything with eventing because you don't describe what you're trying to do.
Does this make sense of what I'm trying to do?


module DataStorage
class << self
USETHIS = #true/false use in code data or use scriptcall
IMAGELOCATION = "imagepath"
IMAGEEFFECT = ""
FOLLOWINGCHARACTER = #true/false
ISMULTIPLEIMAGES = #true/false
IMAGEAMOUNTINFOLDER = #place the number of photos in folder here (images must be 1.png 2.png 3.png etcetc)
# 1) Subtractive 2) Addative 3) Overlay 4) Negative
end
end

class Scene_OverlayImage < Scene_Base
def start
super
SceneManager.clear
initialize
end

def initialize
@overlayimg = Sprite.new
@overlayimg.bitmap = #I don't know what to put here
@overlayimg.contains.blt = #Not sure about here either
if USETHIS == true
@imglocation = IMAGELOCATION
@imgeffect = IMAGEEFFECT
@following = FOLLOWINGCHARACTER
@multipleimages = ISMULTIPLE
@imgamount = IMAGEAMOUNTINFOLDER
update
end
@imglocation = imglocation
@imgeffect = imgeffect
@following = following
@multipleimages = multipleimages
@imgamount = imgamount
update
end

def update
@overlayimg.location = @actor[1] #Would this even work?
if @multipleimages == true
x = 1
while x != @imgamount do
@overlayimg.bitmap = ( "Graphics/Pictures/" + @imagelocation + "/" + x.to_s + ".png" )#put location here?
end
end
end
end

class Game_Interpreter
def imageoverlay(imglocation, imgeffect, following, multipleimages, imgamount)
SceneManager.call(Scene_OverlayImage)
SceneManager.scene.initialize(imglocation, imgeffect, following, multipleimages, imgamount) #go up to initialize with this data??
end
end


I don't know how else to explain this, sorry for the delay BTW, IRL keeps calling me away.
No, I don't want to know how you want to do something, I want to know what should the resulting effect in the game be?


What should the player do or see when the entire thing is finished?
No, I don't want to know how you want to do something, I want to know what should the resulting effect in the game be?


What should the player do or see when the entire thing is finished?

Hm, I thought that was what the learning ruby section was for, so that I can learn my mistakes and flaws and fix the errors I had made.


However if that is what you want then okay.


Step 1)


Player selects the gender making the body image placed to the left.


[IMG]http://i.imgur.com/qGeQx3P.png[/IMG]


Step 2)


Now that picture 1.png is there from folder "Graphics/Pictures/FemaleMed"


Wait 10 frames


Delete 1.png


Place 2.png



[IMG]http://i.imgur.com/2xFMDm2.png[/IMG]


NOTE: There is no adult content on those images, I have a layered body system that is simply the base body.


Step 3)


Repeat step 2 until every file is placed and removed


Step 4)


After every file has been dealt with (24.png in this case) either loop or stop


For example, if you are hit and the idle animation is at frame 12.png it would inturupt and play "Graphics/Pictures/FemaleMed/Hurt/1.png" playing all of the animation types in there.


Does that make sense?


I'm not trying to be rude it's just that people say the way I type things is sometimes weird.
So basically you want to make a sequence of pictures until the player selects one - most probably to be used as the new bust ingame for the player?


No need to program that all for yourself, that is exactly what the event commands show picture/erase picture and their script equivalents are for.


Basically you can do that completely with events (no need for scripts), but if you want to do that by scripts (either for learning or for further uses), then simply use the script equivalents of those event commands.


One Minute - I try to locate the topic, it's on this forum.


EDIT:


here you go:




No need to reinvent the wheel, there you'll find the existing commands.
Hm, it's close...


I had something like the one I'm looking for in RPGMXP


External link: http://save-point.org/thread-4510.html


^ That is what I was looking for, however that was done in XP
If you want automated animations, the update for the picture needs to go into the game loop - if you place it independently from the game loop you'll freeze the rest of the game.


Could this be what's causing you problems?


You basically have to store all information about every picture that is part of the animation into the picture data structure, because otherwise it will not be available when the gameloop accesses the data.


Sorry, I can't tell you where exactly those commands are as I've never delved deep enough into the engine myself, I only know it from the theoretical side. You might want to read the "bughunting" tutorial linked in my signature for the effects of the game loop and how a wrong entry there can cause timing problems.


Additionally, I suggest you search for Modern Algebra's Advanced Text System (ATS) scripts - one of them contains options to animate faces inside the show text command, that code might give you more hints on how to do that. The ATS scripts are all on the master script list.
If you want automated animations, the update for the picture needs to go into the game loop - if you place it independently from the game loop you'll freeze the rest of the game.


Could this be what's causing you problems?


You basically have to store all information about every picture that is part of the animation into the picture data structure, because otherwise it will not be available when the gameloop accesses the data.


Sorry, I can't tell you where exactly those commands are as I've never delved deep enough into the engine myself, I only know it from the theoretical side. You might want to read the "bughunting" tutorial linked in my signature for the effects of the game loop and how a wrong entry there can cause timing problems.


Additionally, I suggest you search for Modern Algebra's Advanced Text System (ATS) scripts - one of them contains options to animate faces inside the show text command, that code might give you more hints on how to do that. The ATS scripts are all on the master script list.



I do want animated animations.


I know it needs to go into the game loop I just don't know how to make a script that draws a picture on the display.


I understand the following:


To make a script you need a "Script Call" < I do not know how to make this.


To make a image display on the screen you need a "Sprite.new" < I don't know how to use the "Sprite" command and f1 isn't helping


When you make a "image = Sprite.new" you need to do "image.bitmap" < But after that I don't know what to put


To make my characters and the following animations I would need a z location so "image.z" would happen later.


To place a "sprite" on the screen or our "image" we need a "window (or viewport)" < I don't know how to make that


After that the person would then type "image" in the event.


[IMG]http://i.imgur.com/Hp4vVDg.png[/IMG]


So my question in this whole thing is, how do I make a "Sprite.new" place an image in game when the event has a script that says image(path, looping) in which path and looping will put the data put in there into variables.


Because that's all I need, I'm not that "new" to RPGMVXA I am just terrible at making scripts.
nope - you made several wrong assumptions here.


There is a difference between the functions of a script and the script command of the event system.


The script command of the events is a sandboxed minor part of the entire script engine. everything placed inside a script command textbox will be erased when the command is closed. But it is the only way to get something to the true engine itself.


A script call is a call to a function that is defined within the game interpreter, and that function may access parts outside the game interpreter, usually to store data or to initiate other commands. But those other commands that affect the engine itself need to be placed in the script editor outside the game interpreter (which handles the script command of events and event commands.


However, it is not neccessary to make a script call to make the engine react to something - in this specific case you'll probably be better off NOT using script calls from the game interpreter. It would be a lot better to completely ignore the game interpreter and make a special sign in the regular pictures/sprites you assign.


So you only use a single show picture command to display a single picture. But you rewrite the internal display method to check if the filename of the picture has a special name that you selected for yourself, and if yes redirect to an animated display - if not keep going to the regular display.


That is how most scripter do this, because it doesn't involve script calls or the game_interpreter at all.
Could you help with this then, I just need help with the script because I get stuck on the same bloody thing every time.


I already know what I want to do, I already know it's possible and I have a general idea of how to do it, I just keep getting stuck at this ONE part every single time and it's irritating me.


Script 'DrawGraphic' line 36: NoMethodError occurred.


undefined method 'blt' for Bitmap:Class


Bitmap.blt under


def create_window


That's what we're looking at.

Code:
class Window_AnimatedImages < Window_Base
  def initialize(x, y, imgwidth, imgheight)
    super(x, y, 250, 90)
  end
  
  def refresh(img)
    contents.clear
  end
end

class Scene_AnimatedImages < Scene_Base
  def start
    super
    create_window
  end
  
  def prepare(x, y, path, loop, frames)
    @window_x = x
    @window_y = y
    @path = path
    @loop = loop
    @frames = frames
  end
  
  def update
    super
    @frames -= 1
    @animatedimages.refresh(@img)
    SceneManager.return if @frames == 1
  end
  
  def create_window
    @animatedimages_sprite = Sprite.new
    @animatedimages_window = Bitmap.new(@path)
    rect = Rect.new(0, 0, 272, 286)
    @animatedimages_window = Bitmap.blt(@x, @y, @animatedimages_sprite, rect)
  end
end

class Game_Interpreter
  def animatedimages(x, y, path, loop, frames)
    SceneManager.call(Scene_AnimatedImages)
    SceneManager.scene.prepare(x, y, path, loop, frames)
  end
end
Alright, I got it working, the only problem (and I think @Andar mentioned this) when I play the images, the background goes black, the image is there playing and all of that but everything else is black.


I assume it's because my code is in scene?


Is it because my rectangle is causing everything to be black?
Alright, I got it working, the only problem (and I think @Andar mentioned this) when I play the images, the background goes black, the image is there playing and all of that but everything else is black.


I assume it's because my code is in scene?


Is it because my rectangle is causing everything to be black?

Okay I provided a GIF for better explination.


http://i.imgur.com/Lej8s5o.gifv


[IMG]http://i.imgur.com/Lej8s5o.gif[/IMG]

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-create-sprites.63053/