PDA

View Full Version : [Essentials tutorial] How to click buttons using touch screen


carmaniac
August 23rd, 2010, 01:51 PM
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:

@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:

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:

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.

matrockista06
August 29th, 2010, 05:25 AM
WHERE WOUL I POST EACH CODES PLS. HELPT^T

carmaniac
August 29th, 2010, 08:48 AM
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.

bigtukker
August 30th, 2010, 04:31 AM
How can I change the font, and then I mean a less pixelated font.

Luka S.J.
August 31st, 2010, 06:57 AM
That would be kind of irritating to use. The whole method of loading the image is just way too fiddly. How about placing

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

if MouseOver?(@button)

and to make it even more simplified for left clicking

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
September 2nd, 2010, 07:37 AM
---------------------------
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:
@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
September 2nd, 2010, 08:24 AM
---------------------------
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:
@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:

@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

Pichuichu
September 2nd, 2010, 09:32 AM
umm my mouse doesn't show up and i can't click it?

Gigatom~
September 3rd, 2010, 07:33 AM
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
September 3rd, 2010, 07:50 AM
oh okay. thanksfor those tips.

Gigatom~
September 3rd, 2010, 08:13 AM
oh okay. thanksfor those tips.

No Problem :)
Btw, your Pokemon New Dawn Thread layout is amazing,
who made it ?

Pichuichu
September 3rd, 2010, 08:45 AM
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
October 30th, 2010, 04:50 PM
---------------------------
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
December 4th, 2010, 12:44 PM
-----------------
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

DAWJ
December 4th, 2010, 02:10 PM
-----------------
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
December 4th, 2010, 02:49 PM
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))

Felphor
May 24th, 2012, 03:02 PM
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.

abnegation
June 8th, 2012, 05:09 AM
Surprised I didn't see this revival. Do not revive threads over two months old. Thanks.

Locked.

linkthehero
October 30th, 2013, 07:10 AM
hmmmmm the problem is the mouse script don't work =(

Maruno
October 30th, 2013, 07:43 AM
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.