Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials
Reload this Page [Essentials tutorial] How to click buttons using touch screen

Notices
For all updates, view the main page.

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.



Reply
 
Thread Tools
  #1    
Old August 23rd, 2010 (01:51 PM).
carmaniac's Avatar
carmaniac carmaniac is offline
Where the pickle surprise at?
 
Join Date: Apr 2009
Location: England
Age: 20
Nature: Relaxed
Posts: 681
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.
__________________

Pokémon: Lost Souls.







Developed by Carmaniac.
Reply With Quote
  #2    
Old August 29th, 2010 (05:25 AM).
matrockista06 matrockista06 is offline
 
Join Date: Jun 2009
Gender: Male
Posts: 14
WHERE WOUL I POST EACH CODES PLS. HELPT^T
Reply With Quote
  #3    
Old August 29th, 2010 (08:48 AM).
carmaniac's Avatar
carmaniac carmaniac is offline
Where the pickle surprise at?
 
Join Date: Apr 2009
Location: England
Age: 20
Nature: Relaxed
Posts: 681
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.
__________________

Pokémon: Lost Souls.







Developed by Carmaniac.
Reply With Quote
  #4    
Old August 30th, 2010 (04:31 AM).
bigtukker bigtukker is offline
 
Join Date: Mar 2009
Gender:
Posts: 70
How can I change the font, and then I mean a less pixelated font.
Reply With Quote
  #5    
Old August 31st, 2010 (06:57 AM).
Luka S.J.'s Avatar
Luka S.J. Luka S.J. is offline
@LukaSJ0
 
Join Date: Dec 2008
Location: Croatia
Age: 21
Gender: Male
Nature: Adamant
Posts: 877
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?
__________________
Reply With Quote
  #6    
Old September 2nd, 2010 (07:37 AM).
Pichuichu's Avatar
Pichuichu Pichuichu is offline
Creator Of (Insert Here)
 
Join Date: Apr 2010
Location: Isshu-Huin City
Gender: Male
Posts: 273
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
__________________

Credit: Invasion For Sig And Avatar.



My Da Account ->here<-
Reply With Quote
  #7    
Old September 2nd, 2010 (08:24 AM).
Rai Rai's Avatar
Rai Rai Rai Rai is offline
Master of everything!
 
Join Date: Aug 2010
Gender: Male
Posts: 267
Quote originally posted by Pichuichu:
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
Reply With Quote
  #8    
Old September 2nd, 2010 (09:32 AM).
Pichuichu's Avatar
Pichuichu Pichuichu is offline
Creator Of (Insert Here)
 
Join Date: Apr 2010
Location: Isshu-Huin City
Gender: Male
Posts: 273
umm my mouse doesn't show up and i can't click it?
__________________

Credit: Invasion For Sig And Avatar.



My Da Account ->here<-
Reply With Quote
  #9    
Old September 3rd, 2010 (07:33 AM).
Gigatom~'s Avatar
Gigatom~ Gigatom~ is offline
Pokemon Ruthenium Creator ~
 
Join Date: Jan 2010
Age: 19
Gender: Male
Posts: 116
Quote originally posted by Pichuichu:
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.
__________________


Check out my deviantArt! :3
Reply With Quote
  #10    
Old September 3rd, 2010 (07:50 AM).
Pichuichu's Avatar
Pichuichu Pichuichu is offline
Creator Of (Insert Here)
 
Join Date: Apr 2010
Location: Isshu-Huin City
Gender: Male
Posts: 273
oh okay. thanksfor those tips.
__________________

Credit: Invasion For Sig And Avatar.



My Da Account ->here<-
Reply With Quote
  #11    
Old September 3rd, 2010 (08:13 AM).
Gigatom~'s Avatar
Gigatom~ Gigatom~ is offline
Pokemon Ruthenium Creator ~
 
Join Date: Jan 2010
Age: 19
Gender: Male
Posts: 116
Quote originally posted by Pichuichu:
oh okay. thanksfor those tips.
No Problem :)
Btw, your Pokemon New Dawn Thread layout is amazing,
who made it ?
__________________


Check out my deviantArt! :3
Reply With Quote
  #12    
Old September 3rd, 2010 (08:45 AM).
Pichuichu's Avatar
Pichuichu Pichuichu is offline
Creator Of (Insert Here)
 
Join Date: Apr 2010
Location: Isshu-Huin City
Gender: Male
Posts: 273
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?
__________________

Credit: Invasion For Sig And Avatar.



My Da Account ->here<-
Reply With Quote
  #13    
Old October 30th, 2010 (04:50 PM).
Urugamosu's Avatar
Urugamosu Urugamosu is offline
Smiles are free, you know~
Crystal Tier
 
Join Date: Sep 2008
Location: Perth, Australia
Age: 20
Gender: Male
Nature: Gentle
Posts: 470
---------------------------
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?
__________________

Adventures, are sometimes even the simplest things.
ProfileYouTubeRedditBlog
Reply With Quote
  #14    
Old December 4th, 2010 (12:44 PM).
Big Bang Big Bang is offline
Creator Of Pokémon Solstice
 
Join Date: Nov 2010
Location: Not avaliable.
Posts: 6
-----------------
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
__________________
Not avaliable.
Reply With Quote
  #15    
Old December 4th, 2010 (02:10 PM).
DAWJ DAWJ is offline
 
Join Date: Jul 2010
Location: New York
Gender: Male
Nature: Lonely
Posts: 37
Quote originally posted by Big Bang:
-----------------
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
Reply With Quote
  #16    
Old December 4th, 2010 (02:49 PM).
carmaniac's Avatar
carmaniac carmaniac is offline
Where the pickle surprise at?
 
Join Date: Apr 2009
Location: England
Age: 20
Nature: Relaxed
Posts: 681
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))
__________________

Pokémon: Lost Souls.







Developed by Carmaniac.
Reply With Quote
  #17    
Old May 24th, 2012 (03:02 PM).
Felphor Felphor is offline
 
Join Date: Dec 2010
Gender: Male
Posts: 2
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.
Reply With Quote
  #18    
Old June 8th, 2012 (05:09 AM).
seeker's Avatar
seeker seeker is offline
adventure seeker
Platinum Tier
 
Join Date: Apr 2009
Location: Ireland
Age: 22
Posts: 10,639
Surprised I didn't see this revival. Do not revive threads over two months old. Thanks.

Locked.
__________________
<div style="background-image: url('http://i.imgur.com/bHlfm47.gif'); background-repeat: no-repeat; height: 245px; width: 600px; font-family: 'Dosis', 'Josefin Slab', 'Open Sans', sans-serif; font-weight: 200; font-size: 13px; letter-spacing: 1px; color: #282828; padding-top: 66px; padding-left:43px; text-align: left; line-height: 15px;">
<div style="font-size: 22px;">seeker</div>
<i class="fa fa-heart-o"></i> paired to <a href="http://www.pokecommunity.com/member.php?u=67003"><span class="usergroup-mod">adventure</span></a>
<i class="fa fa-code"></i> <div class="usergroup-admin">staff administrator</div>
on a leave of absence</div>
Reply With Quote
  #19    
Old October 30th, 2013 (07:10 AM).
linkthehero's Avatar
linkthehero linkthehero is offline
 
Join Date: Sep 2012
Gender: Male
Posts: 66
hmmmmm the problem is the mouse script don't work =(
Reply With Quote
  #20    
Old October 30th, 2013 (07:43 AM).
Maruno's Avatar
Maruno Maruno is offline
Lead Dev of Pokémon Essentials
Moderator
 
Join Date: Jan 2008
Location: England
Posts: 4,156
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.
__________________
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 12:29 AM.