赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1307 |
最后登录 | 2017-3-11 |
在线时间 | 120 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 120 小时
- 注册时间
- 2011-9-25
- 帖子
- 11
|
本帖最后由 我卡了 于 2011-10-19 13:17 编辑
在站上找到一个关于3D旋转的菜单脚本,但是当点击查看特技是就出现了错误,希望高手帮忙修改下,
脚本分为3部分,就是分别放在3个脚本页面里
第一部分:3D旋转- module Math2
- #角度转弧度
- def angleToRadian(angle)
- return angle*(Math::PI/180)
- end
- #弧度转角度
- def radianToAngle(radian)
- return radian*(180/Math::PI)
- end
-
- #计算正弦值
- def sinD(angle)
- return Math.sin(angleToRadian(angle))
- end
-
- #计算余弦值
- def cosD(angle)
- return Math.cos(angleToRadian(angle))
- end
- #计算反正切
- def atan2D(y, x)
- return radianToAngle(Math.atan2(y, x))
- end
- end
- class RotateMenu_3D
- include Math2
-
- attr_accessor :menu_x
- attr_accessor :menu_y
- attr_accessor :disx
- attr_accessor :disy
- attr_accessor :speed
- attr_accessor :active
- attr_accessor :index
- def initialize
- @active=false
- @menu_x=400
- @menu_y=240
-
- @disx=180
- @disy=10
- @speed=0
-
- @endAngle=90
- @tempAngle=0
- @isRotating=true
-
- backImage=RPG::Cache.picture("back")
-
- @child_num=$game_party.actors.size
- @menu_sprite=[]
- @menu_bitmap=[]
- @index=[]
- for i in 0...$game_party.actors.size
- @menu_bitmap[i]=Bitmap.new(backImage.width,backImage.height)
- @menu_bitmap[i].blt(0,0,backImage,Rect.new(0,0,backImage.width,backImage.height))
-
- sprite=Sprite.new
- sprite.bitmap=@menu_bitmap[i]
-
- sprite.ox=@menu_bitmap[i].width/2
- sprite.oy=@menu_bitmap[i].height/2
- sprite.visible=false
- sprite.z=i+9990
-
- set_actor($game_party.actors[i],sprite)
-
- @menu_sprite.push([sprite,0,0]) #angle, y
-
- @index[i]=i
-
- end
- end
-
- def update
- if @isRotating == true
- depthArray=[] #临时的
- angle = 360 / @child_num
- for z in 0...@child_num
- mc=@menu_sprite[z][0]
- mc.bitmap=@menu_bitmap[z]
-
- @menu_sprite[z][1] = @tempAngle + @speed + angle * z
- @menu_sprite[z][2] = sinD(@menu_sprite[z][1]) * @disy
- mc.x = (cosD(@menu_sprite[z][1]) * @disx + @menu_x).round
- mc.y = @menu_sprite[z][2] + @menu_y
- mc.visible=true
-
- depthArray[z] = [mc,@menu_sprite[z][2]] #mc, y
- setProp(mc,"alpha",@menu_sprite[z][2])
- setProp(mc,"scaleX",@menu_sprite[z][2],0.2,1)
- setProp(mc,"scaleY",@menu_sprite[z][2],0.2,1)
- end
-
- arrange(depthArray);
- ########
- @speed += (@endAngle-@speed) * 0.2; ######此处修改旋转速度
- if ((@speed - @endAngle).abs < 0.1)
- initAngle(false)
-
- if @moveDir==-1
- [email protected]
- @index.insert(0,last)
- elsif @moveDir==1
- [email protected]
- @index.push(frist)
- end
-
- @menu_sprite[@index[0]][0].flash(Color.new(255,255,255,255),40)
- @frame=0
- end
- end
- if @isRotating == false
- @menu_sprite[@index[0]][0].update
-
- return if @active==false
-
- @frame+=1
- return if @frame<=40
-
- if Input.trigger?(Input::LEFT)
- @moveDir=-1
- startRotation(@index[3]) #索引3
- end
-
- if Input.trigger?(Input::RIGHT)
- @moveDir=1
- startRotation(@index[1]) #索引1
- end
- end
- end
-
- def startRotation(index)
- currentIcon = @menu_sprite[index]
- @endAngle = atan2D(currentIcon[2],cosD(currentIcon[1])*@disy)
- @endAngle = (@endAngle> -180 && @endAngle < -90)? -270 - @endAngle:90 - @endAngle
- initAngle(true)
- end
- def dispose
- for i in 0...@child_num
- @menu_sprite[i][0].bitmap.dispose
- @menu_sprite[i][0].dispose
- end
- end
-
- def active=(active)
- @active=active
- if @active==true
- @menu_sprite[@index[0]][0].flash(Color.new(255,255,255,255),40)
- @frame=0
- end
- end
-
- def initAngle(b)
- if (@isRotating)
- @tempAngle += @speed
- end
- @speed = 0
- @isRotating = b
- end
- def arrange(depthArray)
- depthArray.sort!{|a,b|a[1]<=>b[1]}
- i = depthArray.size
- while i>0
- i-=1
- depthArray[i][0].z=i+9990
- end
- end
- def setProp(mc,prop,sy,n1=0.5,n2=1)
- if prop=="alpha"
- opacity = ((sy + 2 * @disy) / @disy - 1) / 2 * (n2 - n1) + n1
- mc.opacity=opacity*255
- elsif prop=="scaleX"
- mc.zoom_x = ((sy + 2 * @disy) / @disy - 1) / 2 * (n2 - n1) + n1
- elsif prop=="scaleY"
- mc.zoom_y = ((sy + 2 * @disy) / @disy - 1) / 2 * (n2 - n1) + n1
- end
- end
- def index
- return @index[0]
- end
-
- def set_actor(actor,sprite)
-
- bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
- src_rect=Rect.new(0,0,bitmap.width,bitmap.height)
- sprite.bitmap.blt(10, 10, bitmap, src_rect)
- sprite.bitmap.font.size=18
-
- sprite.bitmap.font.color = Color.new(192, 224, 255, 255)
- sprite.bitmap.draw_text(128, 10, 24, 24, "Lv")
- sprite.bitmap.font.color = Color.new(255, 255, 255, 255)
- sprite.bitmap.draw_text(128 + 24, 10, 24, 24, actor.level.to_s, 2)
-
- sprite.bitmap.draw_text(128, 36, 120, 24, actor.name)
-
- sprite.bitmap.draw_text(128, 62, 120, 24, actor.class_name)
-
-
- text = make_battler_state_text(actor, 120, true)
- if actor.hp == 0
- sprite.bitmap.font.color = Color.new(255, 64, 0)
- else
- sprite.bitmap.font.color = Color.new(255, 255, 255, 255)
- end
- sprite.bitmap.draw_text(128, 88, 120, 24, text)
-
-
- sprite.bitmap.draw_text(16, 190, 24, 24, $data_system.words.hp)
- if actor.hp == 0
- sprite.bitmap.font.color = Color.new(255, 64, 0)
- elsif actor.hp <= actor.maxhp / 4
- sprite.bitmap.font.color = Color.new(255, 255, 64, 255)
- else
- sprite.bitmap.font.color = Color.new(255, 255, 255, 255)
- end
- sprite.bitmap.draw_text(64,190,48,24,actor.hp.to_s, 2)
- sprite.bitmap.font.color = Color.new(255, 255, 255, 255)
- sprite.bitmap.draw_text(64 + 48, 190, 12, 24, "/", 1)
- sprite.bitmap.draw_text(64 + 60, 190, 48, 24, actor.maxhp.to_s)
-
-
- sprite.bitmap.draw_text(16, 216, 24, 24, $data_system.words.sp)
- if actor.sp == 0
- sprite.bitmap.font.color = Color.new(255, 64, 0)
- elsif actor.sp <= actor.maxsp / 4
- sprite.bitmap.font.color = Color.new(255, 255, 64, 255)
- else
- sprite.bitmap.font.color = Color.new(255, 255, 255, 255)
- end
- sprite.bitmap.draw_text(64,216,48,24,actor.sp.to_s, 2)
- sprite.bitmap.font.color = Color.new(255, 255, 255, 255)
- sprite.bitmap.draw_text(64 + 48, 216, 12, 24, "/", 1)
- sprite.bitmap.draw_text(64 + 60, 216, 48, 24, actor.maxsp.to_s)
-
- end
-
- def make_battler_state_text(battler, width, need_normal)
- # 生成状态名字符串
- text = ""
- for i in battler.states
- if $data_states[i].rating >= 1
- if text == ""
- text = $data_states[i].name
- else
- text = text + "/" + $data_states[i].name
- end
- end
- end
- # 状态名空的字符串是 "[正常]" 的情况下
- if text == ""
- if need_normal
- text = "[正常]"
- end
- else
- # 加上括号
- text = "[" + text + "]"
- end
- # 返回完成后的文字类
- return text
- end
-
- end
复制代码 #################################################
第二部分:★Window_MenuStatus- class Window_MenuStatus < Window_Base
- def initialize
- super(0, 0, 480, 480)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.active = false
- end
- end
复制代码 #################################################
第三部分:★Scene_Menu另外,这篇脚本原来所在的帖子链接是http://rpg.blue/thread-207859-1-6.html
dsu_plus_rewardpost_czw
我卡了于2011-10-19 12:16补充以下内容:
脚本在粘贴过来后,出现了表情图。。汗。。。请版主进来编辑一下吧。。。~~o(>_<)o ~~ |
|