Illusion
December 29th, 2005, 11:03 AM
While making my battle system I really needed the x and y of a picture, but I didn't want to enter random numbers and just see what it does... So when you are showing a picture, add search_something in the loop do then add Input.update if it isn't in there
then make a new definition called search_something
(BTW:You can change "something" into anything you like as long as the one in loop do is identical.)
Then add this in def search_comething:
if Input.press?(Input::DOWN)
@hpbar.y +=2
end
if Input.press?(Input::UP)
@hpbar.y -=2
end
if Input.press?(Input::RIGHT)
@hpbar.x +=2
end
if Input.press?(Input::LEFT)
@hpbar.x -=2
end
if Input.trigger?(Input::C)
print @hpbar.x.to_s+" "+@hpbar.y.to_s
end
end
with replacing @hpbar with the picture you want.
Then when you've found the x and y delete that script.
Here is an example using attached pictures.Just add this in your script editor.
:
class Test_Pokécommunity
def hpbarhero
@hphero = Sprite.new
@hphero.bitmap = RPG::Cache.picture("HPBarHero")
@hphero.x = 242
@hphero.y = 136
@hphero.z = 500
@hphero.zoom_x = 2
@hphero.zoom_y = 2
@hphero.visible = true
@hpbar = Sprite.new
@hpbar.bitmap = RPG::Cache.picture("HPBarMain50")
@hpbar.x = 302
@hpbar.y = 170
@hpbar.z = 500
@hpbar.zoom_x = 2
@hpbar.zoom_y = 2
@hpbar.visible = true
loop do
update_hpbarhero
Graphics.update
Input.update
end
end
def update_hpbarhero
@hpbar.update
if Input.press?(Input::DOWN)
@hpbar.y +=2
end
if Input.press?(Input::UP)
@hpbar.y -=2
end
if Input.press?(Input::RIGHT)
@hpbar.x +=2
end
if Input.press?(Input::LEFT)
@hpbar.x -=2
end
if Input.trigger?(Input::C)
print @hpbar.x.to_s+" "+@hpbar.y.to_s
end
end
end
I hope this is clear because I made it in a hurry..:\
then make a new definition called search_something
(BTW:You can change "something" into anything you like as long as the one in loop do is identical.)
Then add this in def search_comething:
if Input.press?(Input::DOWN)
@hpbar.y +=2
end
if Input.press?(Input::UP)
@hpbar.y -=2
end
if Input.press?(Input::RIGHT)
@hpbar.x +=2
end
if Input.press?(Input::LEFT)
@hpbar.x -=2
end
if Input.trigger?(Input::C)
print @hpbar.x.to_s+" "+@hpbar.y.to_s
end
end
with replacing @hpbar with the picture you want.
Then when you've found the x and y delete that script.
Here is an example using attached pictures.Just add this in your script editor.
:
class Test_Pokécommunity
def hpbarhero
@hphero = Sprite.new
@hphero.bitmap = RPG::Cache.picture("HPBarHero")
@hphero.x = 242
@hphero.y = 136
@hphero.z = 500
@hphero.zoom_x = 2
@hphero.zoom_y = 2
@hphero.visible = true
@hpbar = Sprite.new
@hpbar.bitmap = RPG::Cache.picture("HPBarMain50")
@hpbar.x = 302
@hpbar.y = 170
@hpbar.z = 500
@hpbar.zoom_x = 2
@hpbar.zoom_y = 2
@hpbar.visible = true
loop do
update_hpbarhero
Graphics.update
Input.update
end
end
def update_hpbarhero
@hpbar.update
if Input.press?(Input::DOWN)
@hpbar.y +=2
end
if Input.press?(Input::UP)
@hpbar.y -=2
end
if Input.press?(Input::RIGHT)
@hpbar.x +=2
end
if Input.press?(Input::LEFT)
@hpbar.x -=2
end
if Input.trigger?(Input::C)
print @hpbar.x.to_s+" "+@hpbar.y.to_s
end
end
end
I hope this is clear because I made it in a hurry..:\