猫史档案馆


01-K4积木代码转换(1)

用户:RGB_Codemao2026RGB_Codemao2026查看:0 回复:1 评论:0 创建时间:2023-04-06T21:34:37


01-K4积木代码转换(1)
——————104017358629——————
积木有点多,我分段写吧,不知道一次发帖zui多能写多长…

图例(下同)
积木名字
(积木图片.png)
#!python

import Kitten4 as k4

上排为python代码
//!javascript

下排为JS代码
(如果没有标注py和js,则两个代码完全一样)

 一、事件 
当开始被点击

center_image

#!python

def when_start():
  #具体执行内容

#因为Python的响应事件有限,我猜响应事件应该是这样子的吧(后面的响应事件都一样)
//!javascript

function when_start(){
  //具体执行内容
}

 

当角色被【点击】

center_image

#!python

def when_sprite_clicked():
  #具体执行内容

#clicked  点击
#pressed  按下
#released 放开
//!javascript

function when_sprite_clicked(){
  //具体执行内容
}

//clicked  点击
//pressed  按下
//released 放开

 

当手机被摇晃

center_image

#!python

def when_phone_shaken():
  #具体执行内容
//!javascript

function when_phone_shaken(){
  //具体执行内容
}

 

当手机听到("任何关键字")

center_image

#!python

def when_heard_keyword(keyword='任何关键字'):
  #具体执行内容
//!javascript

function when_heard_keyword(keyword='任何关键字'){
  //具体执行内容
}

 

当手机向【上】倾斜

center_image

#!python

def when_tilt_up():
  #具体执行内容

#up    向上
#down  向下
#left  向左
#right 向右
//!javascript

function when_tilt_up(){
  //具体执行内容
}

//up    向上
//down  向下
//left  向左
//right 向右

 

当手指向【上】滑动

center_image

#!python

def when_slide_up():
  #具体执行内容

#up    向上
#down  向下
#left  向左
#right 向右
//!javascript

function when_slide_up(){
  //具体执行内容
}

//up    向上
//down  向下
//left  向左
//right 向右

 

当【按下】【任意】

center_image

#!python

def when_pressed_key(keycode=0):
  #具体执行内容

#pressed  按下
#released 放开

#keycode值需要在在网上找。
//!javascript

function when_pressed_key(keycode=0){
  //具体执行内容
}

//pressed  按下
//released 放开

 

当〈?〉

center_image

#!python

def when(condition):
  while True:
    if condition:
      #执行相应内容

when(True)
//!javascript

function when(condition){
  while true{
    if condition{
      //执行相应内容
    }
  }
}

when(True)

 

当收到广播(1)

center_image

#!python

def when_get_signal(signal='消息1'):
  #具体执行内容
//!javascript

function when_get_signal(signal='消息1'){
  //具体执行内容
}

 

发送广播(1)

center_image

k4.send_signal('消息1')

 

发送广播(1)并等待

center_image

k4.send_signal_and_wait('消息1')

 

当屏幕切换到【1】

center_image

#!python

def when_scene_changed(scene=1):
  #具体执行内容
//!javascript

function when_scene_changed(scene=1):
  //具体执行内容

 

当进入当前屏幕时

center_image

#!python

def when_entered_current_screen():
  #具体执行内容
//!javascript

function when_entered_current_screen(){
  //具体执行内容
}

 

切换屏幕(1)

center_image

k4.switch_to_screen(1)

 

(kitten 95)切换屏幕(1)并传值(0)

center_image

k4.switch_to_screen_with_value(1,0)

 

设置屏幕切换特效【向上】【移入】

center_image

k4.set_scene_transition(1)

编号 对应特效
 0   无效果
 1   向上移入
 2   向下移入
 3   向左移入
 4   向右移入
 5   向上弹入
 6   向下弹入
 7   向左弹入
 8   向右弹入
 9   渐显
 10  扭曲

 

(kitten 95)(传入本屏幕的值)

center_image

k4.value_of_screen()

 

当作为克隆体启动时

center_image

#!python

def when_clone_made():
  #具体执行内容
//javascript

function when_clone_made(){
  //具体执行内容
}

 

克隆【自己】

center_image

k4.clone('__self')

 

(kitten 95)克隆【自己】并传值(0)

center_image

k4.clone_with_value('__self',0)

备注:如果传值克隆体总数,传入克隆体的值则是克隆角色前的数量。

 

删除自己

center_image

k4.delete_itself()

 

删除本克隆体

center_image

k4.delete_this_clone()

和“删除自己”不一样的是,“删除自己”可以把本体也给删掉,
但“删除本克隆体”只能删除克隆体,并不能删除本体。

 

(当前克隆体编号)

center_image

k4.current_clone_number()

 

(【自己】的克隆体总数)

center_image

k4.amount_of_clone('__self')

 

(【自己】编号(1)克隆体的【X坐标】)

center_image

k4.xcor_of_clone('__self',1)

xcor         X坐标
ycor         Y坐标
angle        角度
style        造型编号
size         大小
width        宽度
height       高度
color        颜色值
transparency 透明度
brightness   亮度
pixelate     像素化
ripple       波纹
distortion   扭曲
grey         黑白
ascii        字符码

 

(kitten 95)(传入【自己】编号(1)克隆体的值)

center_image

k4.value_of_clone('__self',1)

 

停止【全部脚本】

center_image

#!python

k4.stop_all()         #停止【全部脚本】
k4.stop_current()     #停止【当前脚本】
k4.stop_self_others() #停止【当前角色的其它脚本】
k4.stop_others()      #停止【其它角色的脚本】
//!javascript

k4.stop_all()         //停止【全部脚本】
k4.stop_current()     //停止【当前脚本】
k4.stop_self_others() //停止【当前角色的其它脚本】
k4.stop_others()      //停止【其它角色的脚本】

 

停止

center_image

k4.stop()

 

重启

center_image

k4.restart()

 

(未完持续)

特别警告:
1,禁止发戴雨默、光头强情书、被车喵、被缠喵、晚上12点有鬼、向XX开炮、XX秘籍、“好运卡”、

乱码(以及其它要转发到多少个论坛的内容)、刷屏、打广告(包括工作室招人)、骂人、沙发板凳(包括
“ddd”、114514)等违禁内容,一经发现,将会被删除,请大家相互转告,谢谢配合!
2,禁止盗贴,违者后果自负。

The Red-Green-Blue Codemao 2023 特此公告!


回复

上一页1 页 / 共 1下一页
cly33cly33

我发个“6”总行了吧

点赞0


评论