本帖最后由 soulsaga 于 2023-8-12 10:46 编辑 金芒芒 发表于 2023-8-12 07:53 RUBY 代码复制
|
soulsaga 发表于 2023-8-11 23:02 角色偏差了一位0代表1 ,1代表2不过能用 跟士兵ID差1 不过现在敌方是解决enermy_selected_troops =[[[3],[4],[5],[6],[7]] ] 我方team_selected_troops = @selected_units 我就转存不了数字了通过team_selected_troops窗口添加数组 读不出来 b=([[3],[4],[5],[6],[7]]) c=Marshal::load(Marshal.dump(b)) a=c.flatten #p a #=> [3,4,5,6,7] x=544 for i in 0...a.length $game_screen.pictures[i+1].show("头像#{a}", 0,x, 550, 100, 100, 255, 0) x-=87 end |
这是怎么行得通的..没有写错吗? |
qq634488405 发表于 2023-8-10 08:46 谢谢大神补贴 b=([[3],[4],[5],[6],[7]]) c=Marshal::load(Marshal.dump(b)) a=c.flatten #p a #=> [3,4,5,6,7] x=544 for i in 0...a.length $game_screen.pictures[i+1].show("头像#{a }", 0,x, 550, 100, 100, 255, 0) x-=87 end |
你现在这样直接=赋值会有个问题,通过a,b,$game_variables[18]任意一个改变数组其中某个值,其他2个同样会变化,因为x=某数组相当于把该数组的指针赋值给x,所以a,b,$game_variables[18]指向的都是同一个,要让数组a=数组b,建议这么写a=Marshal::load(Marshal.dump(b)) |
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2025-7-2 05:52
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.