• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Essentials Tutorial] How to click buttons using touch screen

carmaniac

Where the pickle surprise at?
671
Posts
15
Years
My original thread can be found at: http://www.planetdev.net/index.php?showtopic=507
Well I'm gonna start up with a high demand from people with the touch screen ability within Pokemon Essentials.
You will need the mouse module and the dualscreen script by Cng. And obviously Pokemon Essentials.

The first step you need to do is create a button graphic about 50X50 in size.
In a script you need to set up the sprite display for the button(Judging that most people will choose the menu script)
To set up the first button display you need to do the following code:

Code:
@button1=Sprite.new
@button1.x = # Change the # to the value of the displayed graphic's verticle appearance
@button1.y = # Change the # to the value of the displayed graphic's horizontal appearance
@button1.z = 100 # This sets the priority of the button over other graphics
@button1.bitmap = RPG::Cache.picture("insert graphic name here") # defines the graphic

That sets up the button graphic for the first button
To set up the mouse part of the script as to where to click and where the mouse needs to be you need to find the loop do method of the script:
Do the following:

Code:
if Mouse.mouse_in_area?(x,y,width,height) # change the x and y to the co-ordinates on screen change the width and height to the size of the graphic
  if Mouse.click?(1) # checks if the left mouse button is clicked
	#this is where you define the actions of the button
  end
end

And that should be all you need to do in-order to set up the whole touch screen method. Just make sure you have set the button up properly with what it needs to do and check that you know exactly what to do within scripting before you try to do this.

Here's an example of a working button:

Code:
	  if Mouse.mouse_in_area?(21,353,60,39)
		if Mouse.click?(1)
		  $game_system.se_play($data_system.decision_se)
		  pbFadeOutIn(99999) {
		  scene=PokemonPokedexScene.new 
		  screen=PokemonPokedex.new(scene) 
		  screen.pbStartScreen 
		  }
		end
	  end

That is an example of a pokedex button.

Well that's it for now but I will add in extra tutorials in the near future.
 

carmaniac

Where the pickle surprise at?
671
Posts
15
Years
You put them in a script that you want a touch screen effect with. I've only shown how to do it so people need to have some basic scripting knowledge otherwise this tutorial is useless.
 

Luka S.J.

Jealous Croatian
1,270
Posts
15
Years
That would be kind of irritating to use. The whole method of loading the image is just way too fiddly. How about placing

Code:
def MouseOver?(image) #place the name of your image (something like @button) only after you've defined its X and Y co-ordinates

  if Mouse.mouse_in_area?(image.x,image.y,image.bitmap.width,image.bitmap.height)
    return true
  else
    return false
  end

end

in PokemonUtilities and if you want to set mouse commands just use

Code:
if MouseOver?(@button)

and to make it even more simplified for left clicking

Code:
def MouseLeftClick?(image) #place the name of your image (something like @button) only after you've defined its X and Y co-ordinates

  if Mouse.mouse_in_area?(image.x,image.y,image.bitmap.width,image.bitmap.height) && Mouse.click?(1)
    return true
  else
    return false
  end

end

don't you think that would make your life a bit easier?
 

Pichuichu

Creator Of (Insert Here)
271
Posts
13
Years
Code:
---------------------------
Pokemon New Dawn1
---------------------------
Script 'Menu' line 6: NoMethodError occurred.

undefined method `mouse_in_area?' for Mouse:Module
---------------------------
OK   
---------------------------

Thats the error i'm getting and here is my script:
Code:
@button1=Sprite.new
@button1.x = 50
@button1.y = 75
@button1.z = 100 # This sets the priority of the button over other graphics
@button1.bitmap = RPG::Cache.picture("Pokedex Button") # defines the graphic
  if Mouse.mouse_in_area?(21,353,60,39)
		if Mouse.click?(1)
		  $game_system.se_play($data_system.decision_se)
		  pbFadeOutIn(99999) {
		  scene=PokemonPokedexScene.new 
		  screen=PokemonPokedex.new(scene) 
		  screen.pbStartScreen 
		  }
		end
	  end
 

Rai Rai

Master of everything!
262
Posts
13
Years
  • Seen Aug 29, 2012
Code:
---------------------------
Pokemon New Dawn1
---------------------------
Script 'Menu' line 6: NoMethodError occurred.

undefined method `mouse_in_area?' for Mouse:Module
---------------------------
OK   
---------------------------

Thats the error i'm getting and here is my script:
Code:
@button1=Sprite.new
@button1.x = 50
@button1.y = 75
@button1.z = 100 # This sets the priority of the button over other graphics
@button1.bitmap = RPG::Cache.picture("Pokedex Button") # defines the graphic
  if Mouse.mouse_in_area?(21,353,60,39)
		if Mouse.click?(1)
		  $game_system.se_play($data_system.decision_se)
		  pbFadeOutIn(99999) {
		  scene=PokemonPokedexScene.new 
		  screen=PokemonPokedex.new(scene) 
		  screen.pbStartScreen 
		  }
		end
	  end

You've set it up wrong. It should be something like this:

Code:
@button1=Sprite.new
@button1.x = 50
@button1.y = 75
@button1.z = 100 # This sets the priority of the button over other graphics
@button1.bitmap = RPG::Cache.picture("Pokedex Button.png") # defines the graphic
update
def update
  if Mouse.mouse_in_area?(50,75,60,39)
    if mouse.click?(1)
      $game_system.se_play($data_system.decision_se)
      pbFadeOutIn(99999) {
      scene=PokemonPokedexScene.new
      screen=PokemonPokedex.new(scene) 
      screen.pbStartScreen 
       }
       end
   end
end
 

Gigatom~

Pokemon Ruthenium Creator ~
117
Posts
14
Years
  • Age 28
  • Seen May 25, 2012
umm my mouse doesn't show up and i can't click it?
Yeah, you'll need to script a bit to make it work.
The Scripts in this thread are only the basics for a TouchScreen.
 

Pichuichu

Creator Of (Insert Here)
271
Posts
13
Years
It says so at the botom of the first post scroll down and look a the credit's. and thanks. Btw when are you posting the ruthenium thread?
 

Urugamosu

Happy, and Searching.
588
Posts
15
Years
---------------------------
Pokemon Essentials
---------------------------
Exception: Errno::EACCES

Message: Permission denied - Data/move2anim.dat

Compiler:3869:in `save_data'

Compiler:3869:in `pbCompileAnimations'

Compiler:3930:in `pbCompileAllData'

Compiler:4027



How do you fix this?
 

Big Bang

Creator Of Pokémon Solstice
6
Posts
13
Years
-----------------
I need some help. -Pokemon Essentials
-----------------

Okay, I want to transfer my player to the starting town. I have applied the Transfer command in the Intro Event, and in the first town, with the same Transfer command in the town. However, Idid place a starting point where the event should have made it so you start there. But, if I open the game(not in RPG Maker XP) it shows the Fameguru words & stuff, then title screen, then you choose your option. If you click NEW GAME, it plays the town's music instead of the intro's music, and it shows up as a black screen with a prompt that comes up saying exactly this:

Script 'PokemonUtilities' line 289: NoMethodError occurred
undefined method ` +' for nil:NilClass
 
37
Posts
13
Years
-----------------
I need some help. -Pokemon Essentials
-----------------

Okay, I want to transfer my player to the starting town. I have applied the Transfer command in the Intro Event, and in the first town, with the same Transfer command in the town. However, Idid place a starting point where the event should have made it so you start there. But, if I open the game(not in RPG Maker XP) it shows the Fameguru words & stuff, then title screen, then you choose your option. If you click NEW GAME, it plays the town's music instead of the intro's music, and it shows up as a black screen with a prompt that comes up saying exactly this:

Script 'PokemonUtilities' line 289: NoMethodError occurred
undefined method ` +' for nil:NilClass

You would get better help by posting this in the pokemon essentials thread(Home page, click game development, then click Pokemon Essentials: Starter kit for RPG maker XP
 

carmaniac

Where the pickle surprise at?
671
Posts
15
Years
Wow, why are people posting errors of essentials in my thread and also breaking the rule of posting in a thread over the allowed time of it being inactive :/. Just confuses me how no one reads TUTORIAL thread :L. But oh well that's new people for ya. (not being biased as there are some clever ones out there(who read))
 
2
Posts
13
Years
  • Seen May 24, 2012
Script

hi, i was wondering if anyone could help me with a scripting problem. im trying to create special npc's like in the old games that...
1) Demonstrate how to catch a pokemon.
2) Have you follow them while they explain the Pc, pokemart and that kinda stuff.
 
10,673
Posts
15
Years
  • Age 30
  • Seen Dec 30, 2023
Surprised I didn't see this revival. Do not revive threads over two months old. Thanks.

Locked.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
I'm not surprised. None of the scripts have been updated in years, and you're supposed to do thing by yourself in order to add the functionality anyway.

Please do a reality check before posting in really old threads.
 
Back
Top