Rai Rai
Master of everything!
- 262
- Posts
- 14
- Years
- Seen Aug 29, 2012
Well, today I announce myself here to give all of you game developers the basics of coding within Essentials. The main aim is to teach those how to make a simple window script with the day to day functions many other developers out there use to make their menus have that extra touch.
Enjoy.
Ps. If you want the code to keep reference without having to keep coming back here, I've put it in at the bottom of the thread.
Made a mistake on the code, on the last end of the code delete it, that will fix the error I made.
Enjoy.
Ps. If you want the code to keep reference without having to keep coming back here, I've put it in at the bottom of the thread.
Made a mistake on the code, on the last end of the code delete it, that will fix the error I made.
![[PokeCommunity.com] Pokémon: Essentials coding 101 [PokeCommunity.com] Pokémon: Essentials coding 101](https://i1004.photobucket.com/albums/af167/carmaniac94/Tutorial.png)
Spoiler:
Code:
class Window_Lesson < SpriteWindow_Base #name of the class which also takes on
#another class name traits
def initialize # need in all window scripts
super(x,y,width,height) # replace inside with what size and place you want it
@Sprites=[] # calls the sprite class, helpful on disposing all the sprites
@Sprites["BG"] = Sprite.new # makes a new graphic
@Sprites["BG"].x = 0 #where it is pace on X axis this case 0
@Sprites["BG"].y = 0 #where it is place on y axis, this case 0
@Sprites["BG"].z = 9999 # The layer picture is on
@Sprites["BG"].bitmap=RPG::Cache.picture("whateveryouwant") #calls the sprite
#==================# Following sectino is needed to show text
@sprites["overlay"]=Sprite.new(@viewport)
@sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height)
@sprites["overlay"].z=9999999
pbSetSystemFont(@sprites["overlay"].bitmap)
@overlay = @sprites["overlay"].bitmap
@overlay.clear
@baseColor=Color.new(12*6,12*6,12*6)
@shadowColor=Color.new(12*14,12*14,12*14)
#==================# Section ended
@Sprites["BG"].opacity=0 # makes transparent
loop do #loops the following command
Graphics.update
Input.update
update #calls update in a loop
if $scene != self
break
end
end
end
end # ends the def
def update # defines update
#===================# Follwing needed to display text
# The first 20 shows where the text will be displayed on the X-Axis
# The second 20 shows where the text will be displayed on the Y-Axis
# If you want to add in more text later on in the code then use the following:
# But without the # infront of the line.
# textPositions.push([_INTL("Load Save1."),230,450,false,@baseColor,@shadowColor])
textPositions=[
[_INTL("Put what ever you want here."),20,20,false,@baseColor,@shadowColor],
]
#===================#
@frame=+1 # makes a frame count
if Input.trigger?(Input::C) # checks if C is pressed
p 'this works' #Pulls a window saying what's inside the ''
end # ends def
if @frame==50 # checks if frame is at a certain amount
@frame=0 #changes frame count back to 0
end
51.times do #loops the method inside the amount of times.
@Sprites["BG"].opacity+=5 #adds 5 onto the opacity everytime
end #ends loop
if Input.trigger?(Input::B)
break # Breaks window
end
end
end # Ends class
#to call window use in a script command Window_Lesson.new
Last edited: