@kuerlulu 谢谢解答,大神能不能再看看下面的代码,好多<< 10不知道是做什么的
attr_reader :sx attr_reader :sy def initialize(x, y) super(nil) self.x = x + 32 self.y = y + 32 self.ox = 16 self.oy = 16 self.z = 100 self.bitmap = Cache.character($game_temp.tshoot_p_name) self.src_rect = Rect.new($game_temp.tshoot_p_index % 4 * 96 + 32, $game_temp.tshoot_p_index / 4 * 128 + 96, 32, 32) @sx = x << 10 @sy = y << 10 @reload = 0 @throw = 0 @anime = 0 end def update_move vx = 0 vy = 0 if Input.press?(Input::A) speed = $game_temp.tshoot_p_speed_slow else speed = $game_temp.tshoot_p_speed end if Input.press?(Input::LEFT) vx = $game_temp.tshoot_move_reverse ? speed : -speed elsif Input.press?(Input::RIGHT) vx = $game_temp.tshoot_move_reverse ? -speed : speed end if Input.press?(Input::UP) vy = $game_temp.tshoot_move_reverse ? speed : -speed elsif Input.press?(Input::DOWN) vy = $game_temp.tshoot_move_reverse ? -speed : speed end if vx != 0 and vy != 0 vx = vx * 7 / 10 vy = vy * 7 / 10 end @sx += vx @sy += vy @sx -= vx if @sx < 0 or @sx > (288 << 10) @sy -= vy if @sy < 0 or @sy > (352 << 10) self.x = (@sx >> 10) + 32 self.y = (@sy >> 10) + 32 end
attr_reader :sx
attr_reader :sy
def initialize(x, y)
super(nil)
self.x = x + 32
self.y = y + 32
self.ox = 16
self.oy = 16
self.z = 100
self.bitmap = Cache.character($game_temp.tshoot_p_name)
self.src_rect = Rect.new($game_temp.tshoot_p_index % 4 * 96 + 32,
$game_temp.tshoot_p_index / 4 * 128 + 96, 32, 32)
@sx = x << 10
@sy = y << 10
@reload = 0
@throw = 0
@anime = 0
end
def update_move
vx = 0
vy = 0
if Input.press?(Input::A)
speed = $game_temp.tshoot_p_speed_slow
else
speed = $game_temp.tshoot_p_speed
end
if Input.press?(Input::LEFT)
vx = $game_temp.tshoot_move_reverse ? speed : -speed
elsif Input.press?(Input::RIGHT)
vx = $game_temp.tshoot_move_reverse ? -speed : speed
end
if Input.press?(Input::UP)
vy = $game_temp.tshoot_move_reverse ? speed : -speed
elsif Input.press?(Input::DOWN)
vy = $game_temp.tshoot_move_reverse ? -speed : speed
end
if vx != 0 and vy != 0
vx = vx * 7 / 10
vy = vy * 7 / 10
end
@sx += vx
@sy += vy
@sx -= vx if @sx < 0 or @sx > (288 << 10)
@sy -= vy if @sy < 0 or @sy > (352 << 10)
self.x = (@sx >> 10) + 32
self.y = (@sy >> 10) + 32
end
|