设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2366|回复: 0
打印 上一主题 下一主题

[已经过期] 鼠标移动按钮报错!!!

[复制链接]

Lv2.观梦者

梦石
0
星屑
365
在线时间
31 小时
注册时间
2014-12-28
帖子
13
跳转到指定楼层
1
发表于 2021-10-17 19:39:40 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x


脚本如下:

def 按钮(x,y,xx,yy)
    mouse_x, mouse_y = Mouse.get_mouse_pos
  if mouse_x> x and mouse_x< xx and mouse_y> y and mouse_y< yy
    if Input.trigger?(Input::C)
      return 3
      end
    return 2
  else
    return 1
  end
end
#============================================================================
#By 华峰    按钮
#============================================================================
class Xz按钮
  def initialize(name,x,y,z = 9999)
    @name = name
    @x = x
    @y = y
    @按钮 = Sprite.new
    @按钮.x,@按钮.y,@按钮.z = x,y,z
    @按钮.bitmap = RPG::Cache.picture(@name+"1")
  end
  
  def dispose
    @按钮.bitmap.dispose
    @按钮.dispose
    @按钮 = nil
  end
  
  def update
    return false if @按钮.nil?
    @按钮.bitmap = RPG::Cache.picture(@name + "1")
    mouse_x, mouse_y = Mouse.get_mouse_pos
    if mouse_x> @x and
      mouse_x< @x + @按钮.bitmap.width and
      mouse_y> @y and
      mouse_y< @y + @按钮.bitmap.height and
      @按钮.bitmap.get_pixel(mouse_x-@按钮.x, mouse_y-@按钮.y).alpha > 0
      @按钮.bitmap = RPG::Cache.picture(@name + "2")
      if Kboard.keyb($Rmouse_BUTTON_L) == 1
      @按钮.bitmap = RPG::Cache.picture(@name + "3")
      $anokt = true
    else
      if $anokt == true
        $anokt = false
       return 3
       end
     end
     return 2
   else
     @按钮.bitmap = RPG::Cache.picture(@name + "1")
      return 1 if Kboard.keyb($Rmouse_BUTTON_L) == 1
     return 1
   end
end


  def update2
    return false if @按钮.nil?
    #@按钮.bitmap = RPG::Cache.picture(@name + "1")
    @按钮.tone.set(0,0,0)
    mouse_x, mouse_y = Mouse.get_mouse_pos
    if mouse_x> @x and
      mouse_x< @x + @按钮.bitmap.width and
      mouse_y> @y and
      mouse_y< @y + @按钮.bitmap.height and
      @按钮.bitmap.get_pixel(mouse_x-@按钮.x, mouse_y-@按钮.y).alpha > 0
      #@按钮.bitmap = RPG::Cache.picture(@name + "2")
      @按钮.tone.set(50,50,50)
      if Kboard.keyb($Rmouse_BUTTON_L) == 1
      #@按钮.bitmap = RPG::Cache.picture(@name + "3")
      @按钮.tone.set(-50,-50,-50)
      $anokt = true
    else
      if $anokt == true
        $anokt = false
       return 3
       end
     end
     return 2
   else
     #@按钮.bitmap = RPG::Cache.picture(@name + "1")
     @按钮.tone.set(0,0,0)
      return 1 if Kboard.keyb($Rmouse_BUTTON_L) == 1
     return 1
   end
  end
end





class Anniu
  def 按钮生成(min = 1, maxa = 1, z = 9999) #区间a-b
    if $anniuq == nil
      $anniu = []
      $anniuq = 0
    end
    for i in min..maxa
    $anniu[i] = Sprite.new
    $anniu[i].z = z
    #$anniu[$anniuq].bitmap = RPG::Cache.picture($anniuname + "1")
  end
  end

def 按钮判断(x,y,name,a,b = nil,c = nil)
    $anniunameq = name
    $anniux = x
    $anniuy = y
    $anniuname = name
    $anniu[a].x = $anniux                               #~~~~此处错误!!!!
    $anniu[a].y = $anniuy
    @b = b
    if @b == nil
    $anniu[a].bitmap = RPG::Cache.picture($anniunameq + "1")
    mouse_x, mouse_y = Mouse.get_mouse_pos
    if mouse_x> $anniux and
      mouse_x< $anniux + $anniu[a].bitmap.width and
      mouse_y> $anniuy and
      mouse_y< $anniuy + $anniu[a].bitmap.height
      if c != nil
      if $anniu[a].bitmap.get_pixel(mouse_x-$anniu[a].x, mouse_y-$anniu[a].y).alpha > 0
      return
      end
      end
      $anniu[a].bitmap = RPG::Cache.picture($anniunameq + "2")
      if Kboard.keyb($Rmouse_BUTTON_L) == 1
      $anniu[a].bitmap = RPG::Cache.picture($anniunameq + "3")
      $anokt = true
    else
      if $anokt == true
        $anokt = false
       return 3
       end
     end
     return 2
   else
     $anniu[a].bitmap = RPG::Cache.picture($anniunameq + "1")
      return 1 if Kboard.keyb($Rmouse_BUTTON_L) == 1
     return 1
   end
else
   $anniu[a].bitmap = RPG::Cache.picture($anniunameq + "4")
end
end
def 按钮释放(min = 1, max = 1) #区间 a-b
   for i in min..max
     #p $anniuq - i
      $anniu[i].dispose
    end
    $anniuq = 0
end
end
#============初始化=========================================================
    $yidongx = []
    $yidongxx = []
    $yidongxxx = []
    $yidongy = []
    $yidongyy = []
    $yidongyyy = []
    $yidongw = []
    $ydpdxxx = []
    $ydpdyyy = []
    $ydpdx = []
    $ydpdxx = []
    $ydpdy = []
    $ydpdyy = []
    $ydpdx1 = []
    $ydpdxx1 = []
    $ydpdy1 = []
    $ydpdyy1 = []
    $ydpdx2 = []
    $ydpdxx2 = []
    $ydpdy2 = []
    $ydpdyy2 = []
    $ydpdx3 = []
    $ydpdxx3 = []
    $ydpdy3 = []
    $ydpdyy3 = []
    $ydpdx4 = []
    $ydpdxx4 = []
    $ydpdy4 = []
    $ydpdyy4 = []
    $ydpdx5 = []
    $ydpdxx5 = []
    $ydpdy5 = []
    $ydpdyy5 = []
#============================================================================
#By 华峰 窗口可移动
#============================================================================
class Yidong
  def 生成(a) #全局按顺序 已经使用的 1
    @@tit = true
    $yidonga = a
    $yidongx[$yidonga] = 0
    $yidongxx[$yidonga] = 0
    $yidongxxx[$yidonga] = 0
    $yidongy[$yidonga] = 0
    $yidongyy[$yidonga] = 0
    $yidongyyy[$yidonga] = 0
    $ydpdxxx[$yidonga] = 0
    $ydpdyyy[$yidonga] = 0
  end
  def 判断(x,y,xx,yy,a,x1 = 0,y1 = 0,xx1 = 0,yy1 = 0,x2 = 0,y2 = 0,xx2 = 0,yy2 = 0,x3 = 0,y3 = 0,xx3 = 0,yy3 = 0,x4 = 0,y4 = 0,xx4 = 0,yy4 = 0,x5 = 0,y5 = 0,xx5 = 0,yy5 = 0)
   $yidonga = a
   $ydpdx[$yidonga] = x + $ydpdxxx[$yidonga]
   $ydpdxx[$yidonga] = xx + $ydpdxxx[$yidonga]
   $ydpdy[$yidonga] = y + $ydpdyyy[$yidonga]
   $ydpdyy[$yidonga] = yy + $ydpdyyy[$yidonga]
   $ydpdx1[$yidonga] = x1 + $ydpdxxx[$yidonga]
   $ydpdxx1[$yidonga] = xx1 + $ydpdxxx[$yidonga]
   $ydpdy1[$yidonga] = y1 + $ydpdyyy[$yidonga]
   $ydpdyy1[$yidonga] = yy1 + $ydpdyyy[$yidonga]
   $ydpdx2[$yidonga] = x2 + $ydpdxxx[$yidonga]
   $ydpdxx2[$yidonga] = xx2 + $ydpdxxx[$yidonga]
   $ydpdy2[$yidonga] = y2 + $ydpdyyy[$yidonga]
   $ydpdyy2[$yidonga] = yy2 + $ydpdyyy[$yidonga]
   $ydpdx3[$yidonga] = x3 + $ydpdxxx[$yidonga]
   $ydpdxx3[$yidonga] = xx3 + $ydpdxxx[$yidonga]
   $ydpdy3[$yidonga] = y3 + $ydpdyyy[$yidonga]
   $ydpdyy3[$yidonga] = yy3 + $ydpdyyy[$yidonga]
   $ydpdx4[$yidonga] = x4 + $ydpdxxx[$yidonga]  
   $ydpdxx4[$yidonga] = xx4 + $ydpdxxx[$yidonga]
   $ydpdy4[$yidonga] = y4 + $ydpdyyy[$yidonga]
   $ydpdyy4[$yidonga] = yy4 + $ydpdyyy[$yidonga]
   $ydpdx5[$yidonga] = x5 + $ydpdxxx[$yidonga]
   $ydpdxx5[$yidonga] = xx5 + $ydpdxxx[$yidonga]
   $ydpdy5[$yidonga] = y5 + $ydpdyyy[$yidonga]
   $ydpdyy5[$yidonga] = yy5 + $ydpdyyy[$yidonga]
     mouse_x, mouse_y = Mouse.get_mouse_pos
    if Kboard.keyb($Rmouse_BUTTON_L) == 1
      if mouse_x> $ydpdx[$yidonga] and mouse_x< $ydpdxx[$yidonga] and mouse_y> $ydpdy[$yidonga] and mouse_y< $ydpdyy[$yidonga]
        if mouse_x> $ydpdx1[$yidonga] and mouse_x< $ydpdxx1[$yidonga] and mouse_y> $ydpdy1[$yidonga] and mouse_y< $ydpdyy1[$yidonga]
         
          elsif mouse_x> $ydpdx2[$yidonga] and mouse_x< $ydpdxx2[$yidonga] and mouse_y> $ydpdy2[$yidonga] and mouse_y< $ydpdyy2[$yidonga]
           
            elsif mouse_x> $ydpdx3[$yidonga] and mouse_x< $ydpdxx3[$yidonga] and mouse_y> $ydpdy3[$yidonga] and mouse_y< $ydpdyy3[$yidonga]
               
              elsif mouse_x> $ydpdx4[$yidonga] and mouse_x< $ydpdxx4[$yidonga] and mouse_y> $ydpdy4[$yidonga] and mouse_y< $ydpdyy4[$yidonga]
               
                elsif mouse_x> $ydpdx5[$yidonga] and mouse_x< $ydpdxx5[$yidonga] and mouse_y> $ydpdy5[$yidonga] and mouse_y< $ydpdyy5[$yidonga]
         
                  else
          if $yidongw[$yidonga] == true
          $yidongxxx[$yidonga] = $yidongxx[$yidonga]
          $yidongyyy[$yidonga] = $yidongyy[$yidonga]
          $yidongw[$yidonga] = false
        end
          if @@tit == true
            $yidongx[$yidonga] = mouse_x
            $yidongy[$yidonga] = mouse_y
          end
          $yidongxx[$yidonga] = mouse_x - $yidongx[$yidonga] + $yidongxxx[$yidonga]
          $yidongyy[$yidonga] = mouse_y - $yidongy[$yidonga] + $yidongyyy[$yidonga]
          $ydpdxxx[$yidonga] = $yidongxx[$yidonga]
          $ydpdyyy[$yidonga] = $yidongyy[$yidonga]
          return 3
         end
       end
     else
      $yidongx[$yidonga] = mouse_x
      $yidongy[$yidonga] = mouse_y
      $yidongw[$yidonga] = true
      @@tit = false
    end
   
      if mouse_x> $ydpdx[$yidonga] and mouse_x< $ydpdxx[$yidonga] and mouse_y> $ydpdy[$yidonga] and mouse_y< $ydpdyy[$yidonga]
        if mouse_x> $ydpdx1[$yidonga] and mouse_x< $ydpdxx1[$yidonga] and mouse_y> $ydpdy1[$yidonga] and mouse_y< $ydpdyy1[$yidonga]
            return 1
          elsif mouse_x> $ydpdx2[$yidonga] and mouse_x< $ydpdxx2[$yidonga] and mouse_y> $ydpdy2[$yidonga] and mouse_y< $ydpdyy2[$yidonga]
              return 1
            elsif mouse_x> $ydpdx3[$yidonga] and mouse_x< $ydpdxx3[$yidonga] and mouse_y> $ydpdy3[$yidonga] and mouse_y< $ydpdyy3[$yidonga]
                return 1
              elsif mouse_x> $ydpdx4[$yidonga] and mouse_x< $ydpdxx4[$yidonga] and mouse_y> $ydpdy4[$yidonga] and mouse_y< $ydpdyy4[$yidonga]
                 return 1
                elsif mouse_x> $ydpdx5[$yidonga] and mouse_x< $ydpdxx5[$yidonga] and mouse_y> $ydpdy5[$yidonga] and mouse_y< $ydpdyy5[$yidonga]
                  return 1
                else
                  if Input.trigger?(Input::B)
                    return 2
                  end
                end
                else
                  return 0
                  end
  end
  def x(a)
    $yidonga = a
    return $ydpdxxx[$yidonga]
  end
  def y(a)
    $yidonga = a
    return $ydpdyyy[$yidonga]
  end
end
#============================================================================
class Anniu2
  def 按钮生成(maxa) #最大数量1为第一
  for i in 1..maxa
    if $anniuq2 == nil
      $anniu2 = []
      $anniuq2 = 0
      end
    $anniu2[$anniuq2] = Sprite.new
    $anniu2[$anniuq2].z = 9999
    #$anniu[$anniuq].bitmap = RPG::Cache.picture($anniuname + "1")
    $anniuq2 += 1
  end
  end

def 按钮判断(x,y,name,a,b = nil)
   $anniuqq2 = a - 1
   $anniunameq2 = name
    $anniux2 = x
    $anniuy2 = y
    $anniuname2 = name
    $anniu2[$anniuqq2].x = $anniux2
    $anniu2[$anniuqq2].y = $anniuy2
    @b = b
    if @b == nil
    $anniu2[$anniuqq2].bitmap = RPG::Cache.picture($anniunameq2 + "1")
    mouse_x, mouse_y = Mouse.get_mouse_pos
    if mouse_x> $anniux2 and mouse_x< $anniux2 + $anniu2[$anniuqq2].bitmap.width and mouse_y> $anniuy2 and mouse_y< $anniuy2 + $anniu2[$anniuqq2].bitmap.height and
     $anniu2[$anniuqq2].bitmap.get_pixel(mouse_x-$anniu2[$anniuqq2].x, mouse_y-$anniu2[$anniuqq2].y).alpha > 0
      $anniu2[$anniuqq2].bitmap = RPG::Cache.picture($anniunameq2 + "2")
      if Kboard.keyb($Rmouse_BUTTON_L) == 1
      $anniu2[$anniuqq2].bitmap = RPG::Cache.picture($anniunameq2 + "3")
      $anokt2 = true
    else
      if $anokt2 == true
        $anokt2 = false
       return 3
       end
     end
      return 2
    else
      $anniu2[$anniuqq2].bitmap = RPG::Cache.picture($anniunameq2 + "1")
      return 1 if Kboard.keyb($Rmouse_BUTTON_L) == 1
     return 1
   end
else
   $anniu2[$anniuqq2].bitmap = RPG::Cache.picture($anniunameq2 + "4")
end
end
def 按钮释放
   for i in 1..$anniuq2
     #p $anniuq - i
      $anniu2[$anniuq2 - i].dispose
    end
    $anniuq2 = 0
end
end

e4b9f280ec75ff5bdcfe6f617c54dc2.png (314.42 KB, 下载次数: 15)

错误信息

错误信息
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-12-12 21:12

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表