当前位置: 首页 > news >正文

黄岐网站制作电商平台网站

黄岐网站制作,电商平台网站,网站域名做跳转要收费吗,wordpress非凡主题里导航下拉菜单1.搜索godot国内镜像,直接安装,mono是csharp版本 2.直接解压,50m,无需安装,直接运行 3.godot里分为场景,节点 主场景用control场景,下面挂textureact放背景图片,右键实例化子场景把…

 1.搜索godot国内镜像,直接安装,mono是csharp版本

2.直接解压,50m,无需安装,直接运行 

3.godot里分为场景,节点

主场景用control场景,下面挂textureact放背景图片,右键实例化子场景把角色场景加进来

角色场景用node2d场景,下面挂node2d节点,下面挂sprite节点放图片做player

子弹场景用node2d场景,下面挂label节点写一个“O”做子弹

如下:

4.sprite脚本

extends Sprite2D  # 继承自Node2D,或者如果你的角色是一个精灵,可以继承自Sprite  #var speed = 200  # 角色的移动速度,可以根据需要调整  
var bullet_speed = 100
var bullet_instance = null
@onready var bullet_scene = preload("res://botton.tscn")  
@onready var player_sprite = $player_sprite
var flag = 0;# 当节点首次进入场景树时被调用  
func _ready():  if(player_sprite == null):print("player_sprite null>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")flag = 1;pass  # 初始化代码可以放在这里,但在这个例子中我们不需要  func field_booton():bullet_instance = bullet_scene.instantiate() get_tree().root.add_child(bullet_instance)if(player_sprite):bullet_instance.position = player_sprite.positionelse:bullet_instance.position = position	func _process(delta):  var velocity = Vector2.ZERO  # 初始化速度为0  # 检测WSAD键并设置相应的速度  if Input.is_action_pressed("ui_up"):  #velocity.y -= 1  position = position + Vector2(0, -5)if Input.is_action_pressed("ui_down"):  #velocity.y += 1  position = position + Vector2(0, 5)if Input.is_action_pressed("ui_left"):  #velocity.x -= 1  position = position + Vector2(-5, 0)if Input.is_action_pressed("ui_right"):  #velocity.x += 1  position = position + Vector2(5, 0)if Input.is_action_just_pressed("ui_accept"):  field_booton()# 标准化速度向量(可选,取决于你是否想要对角移动速度保持一致)  #if velocity.length_squared() > 0:  #velocity = velocity.normalized() * speed  # 更新角色的位置  #position += velocity * deltaif bullet_instance:bullet_instance.position.x += bullet_speed * delta

注意:
1、应该用delta保持不同平台的移动是一样的

2、@onready var player_sprite = $player_sprite:这个拿到的是null,不知道为什么:为什么是null,因为$是在子节点里找child,我们加脚本应该在node2d里加,不应该在sprite2d里加

3、onready已经被废弃,使用@onready

4、instanse()已经被废弃,使用instansite()

5、不能直接add_child(bullet_instance),而是应该get_tree().root.add_child(bullet_instance),不然子弹和sprite其实是一个节点,上下移动都是相对的

 5.botton脚本

extends Label# Called when the node enters the scene tree for the first time.
func _ready():pass # Replace with function body.# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):position = position + Vector2(4, 0)pass

6.注意connect在godot4也被改了,改成两个参数了

func _ready():
# 假设我们有一个 Button 节点实例,并且我们想要连接其 'pressed' 信号到一个函数  connect("button_down", self._on_button_pressed)  # 然后定义处理按钮点击的函数  
func _on_button_pressed():  print("click the button")pass # Replace with function body.

7.注意button只能是contrl和node的子类,不能是node2d的子类

8.注意层级关系 

场景
main(contrl)
--background(textureact)
--player(node2d, this position add script)--player(sprite),preload(res//boom.tscn)
--A(contrl)--A(button), preload(res//menu.tscn)资源
menu.tscn(button)--get_tree().root.add_child()
boom.tscn(label or others)--get_tree().root.add_child()

9.lable不能放在node下面,应该放在node2的下面

http://www.hkea.cn/news/92284/

相关文章:

  • 山西网站建设排名seo技术培训山东
  • 日韩系成人影片成首选网站如何优化推广
  • 网站到期续费通知搜索风云排行榜
  • 网站公司说我们做的网站服务器不够用哪个杭州seo好
  • 类似淘宝网站建设费用杭州哪家seo公司好
  • 装修网站怎样做seo专员很难吗
  • 无锡网站外包如何接广告赚钱
  • 英文网站制作 官网淘宝标题优化网站
  • 电力建设网站网络推广网站的方法
  • 如何做网站窗口网站优化网络推广seo
  • 营销型网站建设效果网络营销策划推广方案
  • 专业的网站搭建多少钱网站seo优化价格
  • 广州公司网站设计制作win10优化大师官网
  • 做调查哪个网站比较可靠百度指数查询
  • 怎么在建设厅网站报名广州网站优化服务
  • 怎么用dw做静态网站b站好看的纪录片免费
  • 济南网站建设那家好网站制作公司有哪些
  • 域名和网站名不一样营销公司
  • discuz做电影网站免费网站seo
  • 惠民建设局网站明年2024年有疫情吗
  • 卫龙的网站是谁做的今日的新闻
  • 厚街找人做网站动态网站设计
  • 永春县住房和城乡规划建设局网站太原seo排名优化软件
  • 怎么上网站后台爱站小工具计算器
  • 网页编辑岗位职责seo上海优化
  • 网站做二维码吗做网站的外包公司
  • 郑州市中原区疫情最新消息上海网站营销seo方案
  • 狂人站群系统中国最权威的网站排名
  • 简单网站开发实例网站运营工作的基本内容
  • 飞机免费代理ip爱站网seo综合查询工具