using Godot;
using System;
public partial class player : Area2D
{
[Export]
private int speed = 400;
private int screen_size;//屏幕尺寸
private Vector2 velocity = Vector2.Zero;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
//获取窗口尺寸
Vector2 screenSize = GetViewportRect().Size;
GD.Print("screenSize: " + screenSize.ToString());
GD.Print("screenSize: " + screenSize);
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
//Vector2 velocity = Vector2.Zero;
if (Input.IsActionPressed("right")) {
GD.Print("right: " + velocity);
//velocity.x += 1;
Vector2 vector2 = new Vector2();
vector2.x = 1;
}else if (Input.IsActionPressed("left")){
//velocity.x -= 1;
}else if (Input.IsActionPressed("down")){
//velocity.y += 1;
}else if(Input.IsActionPressed("up")) {
//velocity.y -= 1;
}
}
}
各位大神帮我看下这个vector2 怎么赋值啊
CS1061: “Vector2”未包含“x”的定义,并且找不到可接受第一个“Vector2”类型参数的可访问扩展方法“x”(是否缺少 using 指令或程序集引用?) D:\GODOT\game_project\mono\ParallaxBackground视差滚动背景的节点和ParallaxLayer使用ParallaxBackground的视差滚动层\scripts\player.cs(36,12)
using System;
public partial class player : Area2D
{
[Export]
private int speed = 400;
private int screen_size;//屏幕尺寸
private Vector2 velocity = Vector2.Zero;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
//获取窗口尺寸
Vector2 screenSize = GetViewportRect().Size;
GD.Print("screenSize: " + screenSize.ToString());
GD.Print("screenSize: " + screenSize);
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
//Vector2 velocity = Vector2.Zero;
if (Input.IsActionPressed("right")) {
GD.Print("right: " + velocity);
//velocity.x += 1;
Vector2 vector2 = new Vector2();
vector2.x = 1;
}else if (Input.IsActionPressed("left")){
//velocity.x -= 1;
}else if (Input.IsActionPressed("down")){
//velocity.y += 1;
}else if(Input.IsActionPressed("up")) {
//velocity.y -= 1;
}
}
}
各位大神帮我看下这个vector2 怎么赋值啊
CS1061: “Vector2”未包含“x”的定义,并且找不到可接受第一个“Vector2”类型参数的可访问扩展方法“x”(是否缺少 using 指令或程序集引用?) D:\GODOT\game_project\mono\ParallaxBackground视差滚动背景的节点和ParallaxLayer使用ParallaxBackground的视差滚动层\scripts\player.cs(36,12)