- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在创建一个无限的横向卷轴运行游戏。我在尝试将图像应用到我的播放器图标时遇到了障碍 - (function Player
当前是一个红色方 block ) - 这导致游戏传递错误:Uncaught TypeError:这 is.css 不是一个函数
。
到目前为止,我尝试实现这一目标的一些想法是:
this.background
ctx.drawImage()
this.return
img.src
想法?预先感谢您提供的任何帮助。
注意:运行下面的代码可能需要整页才能查看,具体取决于您的屏幕尺寸。
var i = 0;
function random( min, max ) {
return Math.round( min + ( Math.random() * ( max - min ) ) );
}
function randomChoice(array){
return array[ Math.round( random( 0, array.length - 1 ) ) ];
}
var InfiniteRunner = Sketch.create({
fullscreen: false,
width: 640,
height: 400 ,
container: document.getElementById('container')
});
/*******************/
/*****VECTOR2*******/
/*******************/
function Vector2(x, y, width, height){
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.previousX = 0;
this.previousY = 0;
};
Vector2.prototype.setPosition = function(x, y) {
this.previousX = this.x;
this.previousY = this.y;
this.x = x;
this.y = y;
};
Vector2.prototype.setX = function(x) {
this.previousX = this.x;
this.x = x;
};
Vector2.prototype.setY = function(y) {
this.previousY = this.y;
this.y = y;
};
Vector2.prototype.insercects = function(obj){
if(obj.x < this.x + this.width && obj.y < this.y + this.height &&
obj.x + obj.width > this.x && obj.y + obj.height > this.y ){
return true;
}
return false;
};
Vector2.prototype.insercectsLeft = function(obj){
if(obj.x < this.x + this.width && obj.y < this.y + this.height ){
return true;
}
return false;
};
/****************/
/*****PLAYER*****/
/****************/
function Player(options){
this.setPosition(options.x, options.y);
this.width = options.width;
this.height = options.height;
this.velocityX = 0;
this.velocityY = 0;
this.jumpSize = -13;
this.color = 'rgba(245,44,22,1)';
}
Player.prototype = new Vector2;
Player.prototype.update = function() {
this.velocityY += 1;
this.setPosition(this.x + this.velocityX, this.y + this.velocityY);
if(this.y > InfiniteRunner.height || this.x + this.width < 0){
this.x = 150;
this.y = 50;
this.velocityX = 0;
this.velocityY = 0;
InfiniteRunner.jumpCount = 0;
InfiniteRunner.aceleration = 0;
InfiniteRunner.acelerationTweening = 0;
InfiniteRunner.scoreColor = '#ffffff';
InfiniteRunner.platformManager.maxDistanceBetween = 350;
InfiniteRunner.platformManager.updateWhenLose();
}
if((InfiniteRunner.keys.UP || InfiniteRunner.keys.SPACE || InfiniteRunner.keys.W || InfiniteRunner.dragging) && this.velocityY < -8){
this.velocityY += -0.75;
}
};
Player.prototype.draw = function() {
InfiniteRunner.fillStyle = this.color;
InfiniteRunner.fillRect(this.x, this.y, this.width, this.height);
};
/*******************/
/*****platform****/
/******************/
function Platform(options){
this.x = options.x;
this.y = options.y;
this.width = options.width;
this.height = options.height;
this.previousX = 0;
this.previousY = 0;
this.color = options.color;
}
Platform.prototype = new Vector2;
Platform.prototype.draw = function() {
InfiniteRunner.fillStyle = this.color;
InfiniteRunner.fillRect(this.x, this.y, this.width, this.height);
};
/*******************PLATFORM MANAGER*************/
function PlatformManager(){
this.maxDistanceBetween = 300;
this.colors = ['#006494', '#247ba0', '#1b98e0', '#e8f1f2'];
this.first = new Platform({x: 300, y: InfiniteRunner.width / 2, width: 400, height: 70})
this.second = new Platform({x: (this.first.x + this.first.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween), y: random(this.first.y - 128, InfiniteRunner.height - 80), width: 400, height: 70})
this.third = new Platform({x: (this.second.x + this.second.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween), y: random(this.second.y - 128, InfiniteRunner.height - 80), width: 400, height: 70})
this.first.height = this.first.y + InfiniteRunner.height;
this.second.height = this.second.y + InfiniteRunner.height;
this.third.height = this.third.y + InfiniteRunner.height;
this.first.color = randomChoice(this.colors);
this.second.color = randomChoice(this.colors);
this.third.color = randomChoice(this.colors);
this.colliding = false;
this.platforms = [this.first, this.second, this.third];
}
PlatformManager.prototype.update = function() {
this.first.x -= 3 + InfiniteRunner.aceleration;
if(this.first.x + this.first.width < 0 ){
this.first.width = random(450, InfiniteRunner.width + 200);
this.first.x = (this.third.x + this.third.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
this.first.y = random(this.third.y - 32, InfiniteRunner.height - 80);
this.first.height = this.first.y + InfiniteRunner.height + 10;
this.first.color = randomChoice(this.colors);
}
this.second.x -= 3 + InfiniteRunner.aceleration;
if(this.second.x + this.second.width < 0 ){
this.second.width = random(450, InfiniteRunner.width + 200);
this.second.x = (this.first.x + this.first.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
this.second.y = random(this.first.y - 32, InfiniteRunner.height - 80);
this.second.height = this.second.y + InfiniteRunner.height + 10;
this.second.color = randomChoice(this.colors);
}
this.third.x -= 3 + InfiniteRunner.aceleration;
if(this.third.x + this.third.width < 0 ){
this.third.width = random(450, InfiniteRunner.width + 200);
this.third.x = (this.second.x + this.second.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
this.third.y = random(this.second.y - 32, InfiniteRunner.height - 80);
this.third.height = this.third.y + InfiniteRunner.height + 10;
this.third.color = randomChoice(this.colors);
}
};
PlatformManager.prototype.updateWhenLose = function() {
this.first.x = 300;
this.first.color = randomChoice(this.colors);
this.first.y = InfiniteRunner.width / random(2,3);
this.second.x = (this.first.x + this.first.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
this.third.x = (this.second.x + this.second.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
};
/*******************PARTICLE SYSTEM*************/
function Particle(options){
this.x = options.x;
this.y = options.y;
this.size = 10;
this.velocityX = options.velocityX || random(-(InfiniteRunner.aceleration * 3) + -8,-(InfiniteRunner.aceleration * 3));
this.velocityY = options.velocityY || random(-(InfiniteRunner.aceleration * 3) + -8,-(InfiniteRunner.aceleration * 3));
this.color = options.color;
}
Particle.prototype.update = function() {
this.x += this.velocityX;
this.y += this.velocityY;
this.size *= 0.89;
};
Particle.prototype.draw = function() {
InfiniteRunner.fillStyle = this.color;
InfiniteRunner.fillRect(this.x, this.y, this.size, this.size);
};
/************************************************/
InfiniteRunner.setup = function () {
this.jumpCount = 0;
this.aceleration = 0;
this.acelerationTweening = 0;
this.player = new Player({x: 150, y: 30, width: 32, height: 32});
this.platformManager = new PlatformManager();
this.particles = [];
this.particlesIndex = 0;
this.particlesMax = 2000;
this.collidedPlatform = null;
this.scoreColor = '#ffffff';
this.jumpCountRecord = 0;
};
InfiniteRunner.update = function() {
this.player.update();
switch(this.jumpCount){
case 10:
this.acelerationTweening = 1;
this.platformManager.maxDistanceBetween = 430;
this.scoreColor = '#ffffff';
break;
case 25:
this.acelerationTweening = 2;
this.platformManager.maxDistanceBetween = 530;
this.scoreColor = '#ffffff';
break;
case 40:
this.acelerationTweening = 3;
this.platformManager.maxDistanceBetween = 580;
this.scoreColor = '#ffffff';
break;
}
this.aceleration += (this.acelerationTweening - this.aceleration) * 0.01;
for (i = 0; i < this.platformManager.platforms.length; i++) {
if(this.player.insercects(this.platformManager.platforms[i])){
this.collidedPlatform = this.platformManager.platforms[i];
if (this.player.y < this.platformManager.platforms[i].y) {
this.player.y = this.platformManager.platforms[i].y;
this.player.velocityY = 0;
}
this.player.x = this.player.previousX;
this.player.y = this.player.previousY;
this.particles[(this.particlesIndex++)%this.particlesMax] = new Particle({
x: this.player.x,
y: this.player.y + this.player.height,
color: this.collidedPlatform.color
});
if(this.player.insercectsLeft(this.platformManager.platforms[i])){
this.player.x = this.collidedPlatform.x - 64;
for (i = 0; i < 10; i++) {
this.particles[(this.particlesIndex++)%this.particlesMax] = new Particle({
x: this.player.x + this.player.width,
y: random(this.player.y, this.player.y + this.player.height),
velocityY: random(-30,30),
color: randomChoice(['#ffffff','#ffffff', this.collidedPlatform.color])
});
};
this.player.velocityY = -10 + -(this.aceleration * 4);
this.player.velocityX = -20 + -(this.aceleration * 4);
// this.jumpCount = 0;
// this.aceleration = 0;
// this.acelerationTweening = 0;
// this.scoreColor = '#181818';
// this.platformManager.maxDistanceBetween = 350;
// this.platformManager.updateWhenLose();
} else {
if(this.dragging || this.keys.SPACE || this.keys.UP || this.keys.W){
this.player.velocityY = this.player.jumpSize;
this.jumpCount++;
if(this.jumpCount > this.jumpCountRecord){
this.jumpCountRecord = this.jumpCount;
}
}
}
}
};
for (i = 0; i < this.platformManager.platforms.length; i++) {
this.platformManager.update();
};
for (i = 0; i < this.particles.length; i++) {
this.particles[i].update();
};
};
InfiniteRunner.draw = function(){
this.player.draw();
for (i = 0; i < this.platformManager.platforms.length; i++) {
this.platformManager.platforms[i].draw();
};
for (i = 0; i < this.particles.length; i++) {
this.particles[i].draw();
};
this.font = '12pt Arial';
this.fillStyle = '#ffffff';
this.fillText('RECORD: '+this.jumpCountRecord, this.width - (150 + (this.aceleration * 4)), 33 - (this.aceleration * 4));
this.fillStyle = this.scoreColor;
this.font = (12 + (this.aceleration * 3))+'pt Arial';
this.fillText('JUMPS: '+this.jumpCount, this.width - (150 + (this.aceleration * 4)), 50);
};
InfiniteRunner.resize = function() {
};
body{
background: rgb(227,227,227);
overflow: hidden;
margin: 0;
padding: 0;
text-align: center;
}
#container{
margin-top: 1%;
display: inline-block;
}
canvas{
background: rgb(19,41,61);
border: 1px solid rgb(0,0,0);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sketch.js/1.0.0/sketch.min.js"></script>
<script src="https://s.codepen.io/assets/libs/modernizr.js"></script>
<div id="container"></div>
<div class="controls"></div>
最佳答案
您必须使用 Canvas 的drawImage
方法。
但是您需要首先加载图像(一种方法是在 DOM 中添加元素以便加载它,另一种方法是在内存中创建图像并加载您想要的文件)
我更新了您的代码以支持将 img DOM 元素传递给 Player
构造函数,该构造函数将用作 Sprite ,并更新了绘制方法以使用 drawImage
InfiniteRunner.drawImage(this.sprite, this.x, this.y, this.width, this.height);
<小时/>
更新了代码
var i = 0;
function random( min, max ) {
return Math.round( min + ( Math.random() * ( max - min ) ) );
}
function randomChoice(array){
return array[ Math.round( random( 0, array.length - 1 ) ) ];
}
var InfiniteRunner = Sketch.create({
fullscreen: false,
width: 640,
height: 400 ,
container: document.getElementById('container')
});
/*******************/
/*****VECTOR2*******/
/*******************/
function Vector2(x, y, width, height){
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.previousX = 0;
this.previousY = 0;
};
Vector2.prototype.setPosition = function(x, y) {
this.previousX = this.x;
this.previousY = this.y;
this.x = x;
this.y = y;
};
Vector2.prototype.setX = function(x) {
this.previousX = this.x;
this.x = x;
};
Vector2.prototype.setY = function(y) {
this.previousY = this.y;
this.y = y;
};
Vector2.prototype.insercects = function(obj){
if(obj.x < this.x + this.width && obj.y < this.y + this.height &&
obj.x + obj.width > this.x && obj.y + obj.height > this.y ){
return true;
}
return false;
};
Vector2.prototype.insercectsLeft = function(obj){
if(obj.x < this.x + this.width && obj.y < this.y + this.height ){
return true;
}
return false;
};
/****************/
/*****PLAYER*****/
/****************/
function Player(options){
this.setPosition(options.x, options.y);
this.width = options.width;
this.height = options.height;
this.sprite = options.sprite;
this.velocityX = 0;
this.velocityY = 0;
this.jumpSize = -13;
this.color = 'rgba(245,44,22,1)';
}
Player.prototype = new Vector2;
Player.prototype.update = function() {
this.velocityY += 1;
this.setPosition(this.x + this.velocityX, this.y + this.velocityY);
if(this.y > InfiniteRunner.height || this.x + this.width < 0){
this.x = 150;
this.y = 50;
this.velocityX = 0;
this.velocityY = 0;
InfiniteRunner.jumpCount = 0;
InfiniteRunner.aceleration = 0;
InfiniteRunner.acelerationTweening = 0;
InfiniteRunner.scoreColor = '#ffffff';
InfiniteRunner.platformManager.maxDistanceBetween = 350;
InfiniteRunner.platformManager.updateWhenLose();
}
if((InfiniteRunner.keys.UP || InfiniteRunner.keys.SPACE || InfiniteRunner.keys.W || InfiniteRunner.dragging) && this.velocityY < -8){
this.velocityY += -0.75;
}
};
Player.prototype.draw = function() {
InfiniteRunner.fillStyle = this.color;
//InfiniteRunner.fillRect(this.x, this.y, this.width, this.height);
InfiniteRunner.drawImage(this.sprite, this.x, this.y, this.width, this.height);
};
/*******************/
/*****platform****/
/******************/
function Platform(options){
this.x = options.x;
this.y = options.y;
this.width = options.width;
this.height = options.height;
this.previousX = 0;
this.previousY = 0;
this.color = options.color;
}
Platform.prototype = new Vector2;
Platform.prototype.draw = function() {
InfiniteRunner.fillStyle = this.color;
InfiniteRunner.fillRect(this.x, this.y, this.width, this.height);
};
/*******************PLATFORM MANAGER*************/
function PlatformManager(){
this.maxDistanceBetween = 300;
this.colors = ['#006494', '#247ba0', '#1b98e0', '#e8f1f2'];
this.first = new Platform({x: 300, y: InfiniteRunner.width / 2, width: 400, height: 70})
this.second = new Platform({x: (this.first.x + this.first.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween), y: random(this.first.y - 128, InfiniteRunner.height - 80), width: 400, height: 70})
this.third = new Platform({x: (this.second.x + this.second.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween), y: random(this.second.y - 128, InfiniteRunner.height - 80), width: 400, height: 70})
this.first.height = this.first.y + InfiniteRunner.height;
this.second.height = this.second.y + InfiniteRunner.height;
this.third.height = this.third.y + InfiniteRunner.height;
this.first.color = randomChoice(this.colors);
this.second.color = randomChoice(this.colors);
this.third.color = randomChoice(this.colors);
this.colliding = false;
this.platforms = [this.first, this.second, this.third];
}
PlatformManager.prototype.update = function() {
this.first.x -= 3 + InfiniteRunner.aceleration;
if(this.first.x + this.first.width < 0 ){
this.first.width = random(450, InfiniteRunner.width + 200);
this.first.x = (this.third.x + this.third.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
this.first.y = random(this.third.y - 32, InfiniteRunner.height - 80);
this.first.height = this.first.y + InfiniteRunner.height + 10;
this.first.color = randomChoice(this.colors);
}
this.second.x -= 3 + InfiniteRunner.aceleration;
if(this.second.x + this.second.width < 0 ){
this.second.width = random(450, InfiniteRunner.width + 200);
this.second.x = (this.first.x + this.first.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
this.second.y = random(this.first.y - 32, InfiniteRunner.height - 80);
this.second.height = this.second.y + InfiniteRunner.height + 10;
this.second.color = randomChoice(this.colors);
}
this.third.x -= 3 + InfiniteRunner.aceleration;
if(this.third.x + this.third.width < 0 ){
this.third.width = random(450, InfiniteRunner.width + 200);
this.third.x = (this.second.x + this.second.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
this.third.y = random(this.second.y - 32, InfiniteRunner.height - 80);
this.third.height = this.third.y + InfiniteRunner.height + 10;
this.third.color = randomChoice(this.colors);
}
};
PlatformManager.prototype.updateWhenLose = function() {
this.first.x = 300;
this.first.color = randomChoice(this.colors);
this.first.y = InfiniteRunner.width / random(2,3);
this.second.x = (this.first.x + this.first.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
this.third.x = (this.second.x + this.second.width) + random(this.maxDistanceBetween - 150, this.maxDistanceBetween);
};
/*******************PARTICLE SYSTEM*************/
function Particle(options){
this.x = options.x;
this.y = options.y;
this.size = 10;
this.velocityX = options.velocityX || random(-(InfiniteRunner.aceleration * 3) + -8,-(InfiniteRunner.aceleration * 3));
this.velocityY = options.velocityY || random(-(InfiniteRunner.aceleration * 3) + -8,-(InfiniteRunner.aceleration * 3));
this.color = options.color;
}
Particle.prototype.update = function() {
this.x += this.velocityX;
this.y += this.velocityY;
this.size *= 0.89;
};
Particle.prototype.draw = function() {
InfiniteRunner.fillStyle = this.color;
InfiniteRunner.fillRect(this.x, this.y, this.size, this.size);
};
/************************************************/
InfiniteRunner.setup = function () {
this.jumpCount = 0;
this.aceleration = 0;
this.acelerationTweening = 0;
this.player = new Player({x: 150, y: 30, width: 32, height: 32, sprite: document.getElementById('sprite-player')});
this.platformManager = new PlatformManager();
this.particles = [];
this.particlesIndex = 0;
this.particlesMax = 2000;
this.collidedPlatform = null;
this.scoreColor = '#ffffff';
this.jumpCountRecord = 0;
};
InfiniteRunner.update = function() {
this.player.update();
switch(this.jumpCount){
case 10:
this.acelerationTweening = 1;
this.platformManager.maxDistanceBetween = 430;
this.scoreColor = '#ffffff';
break;
case 25:
this.acelerationTweening = 2;
this.platformManager.maxDistanceBetween = 530;
this.scoreColor = '#ffffff';
break;
case 40:
this.acelerationTweening = 3;
this.platformManager.maxDistanceBetween = 580;
this.scoreColor = '#ffffff';
break;
}
this.aceleration += (this.acelerationTweening - this.aceleration) * 0.01;
for (i = 0; i < this.platformManager.platforms.length; i++) {
if(this.player.insercects(this.platformManager.platforms[i])){
this.collidedPlatform = this.platformManager.platforms[i];
if (this.player.y < this.platformManager.platforms[i].y) {
this.player.y = this.platformManager.platforms[i].y;
this.player.velocityY = 0;
}
this.player.x = this.player.previousX;
this.player.y = this.player.previousY;
this.particles[(this.particlesIndex++)%this.particlesMax] = new Particle({
x: this.player.x,
y: this.player.y + this.player.height,
color: this.collidedPlatform.color
});
if(this.player.insercectsLeft(this.platformManager.platforms[i])){
this.player.x = this.collidedPlatform.x - 64;
for (i = 0; i < 10; i++) {
this.particles[(this.particlesIndex++)%this.particlesMax] = new Particle({
x: this.player.x + this.player.width,
y: random(this.player.y, this.player.y + this.player.height),
velocityY: random(-30,30),
color: randomChoice(['#ffffff','#ffffff', this.collidedPlatform.color])
});
};
this.player.velocityY = -10 + -(this.aceleration * 4);
this.player.velocityX = -20 + -(this.aceleration * 4);
// this.jumpCount = 0;
// this.aceleration = 0;
// this.acelerationTweening = 0;
// this.scoreColor = '#181818';
// this.platformManager.maxDistanceBetween = 350;
// this.platformManager.updateWhenLose();
} else {
if(this.dragging || this.keys.SPACE || this.keys.UP || this.keys.W){
this.player.velocityY = this.player.jumpSize;
this.jumpCount++;
if(this.jumpCount > this.jumpCountRecord){
this.jumpCountRecord = this.jumpCount;
}
}
}
}
};
for (i = 0; i < this.platformManager.platforms.length; i++) {
this.platformManager.update();
};
for (i = 0; i < this.particles.length; i++) {
this.particles[i].update();
};
};
InfiniteRunner.draw = function(){
this.player.draw();
for (i = 0; i < this.platformManager.platforms.length; i++) {
this.platformManager.platforms[i].draw();
};
for (i = 0; i < this.particles.length; i++) {
this.particles[i].draw();
};
this.font = '12pt Arial';
this.fillStyle = '#ffffff';
this.fillText('RECORD: '+this.jumpCountRecord, this.width - (150 + (this.aceleration * 4)), 33 - (this.aceleration * 4));
this.fillStyle = this.scoreColor;
this.font = (12 + (this.aceleration * 3))+'pt Arial';
this.fillText('JUMPS: '+this.jumpCount, this.width - (150 + (this.aceleration * 4)), 50);
};
InfiniteRunner.resize = function() {
};
body{
background: rgb(227,227,227);
overflow: hidden;
margin: 0;
padding: 0;
text-align: center;
}
#container{
margin-top: 1%;
display: inline-block;
}
canvas{
background: rgb(19,41,61);
border: 1px solid rgb(0,0,0);
}
.sprites{width:0;height:0;overflow:hidden;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sketch.js/1.0.0/sketch.min.js"></script>
<script src="https://s.codepen.io/assets/libs/modernizr.js"></script>
<div class="sprites">
<img src="https://cdn.kastatic.org/images/avatars/orange-juice-squid.png" id="sprite-player">
</div>
<div id="container"></div>
<div class="controls"></div>
关于javascript - 将动画 gif 分配给播放器函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46777410/
C语言sscanf()函数:从字符串中读取指定格式的数据 头文件: ?
最近,我有一个关于工作预评估的问题,即使查询了每个功能的工作原理,我也不知道如何解决。这是一个伪代码。 下面是一个名为foo()的函数,该函数将被传递一个值并返回一个值。如果将以下值传递给foo函数,
CStr 函数 返回表达式,该表达式已被转换为 String 子类型的 Variant。 CStr(expression) expression 参数是任意有效的表达式。 说明 通常,可以
CSng 函数 返回表达式,该表达式已被转换为 Single 子类型的 Variant。 CSng(expression) expression 参数是任意有效的表达式。 说明 通常,可
CreateObject 函数 创建并返回对 Automation 对象的引用。 CreateObject(servername.typename [, location]) 参数 serv
Cos 函数 返回某个角的余弦值。 Cos(number) number 参数可以是任何将某个角表示为弧度的有效数值表达式。 说明 Cos 函数取某个角并返回直角三角形两边的比值。此比值是
CLng 函数 返回表达式,此表达式已被转换为 Long 子类型的 Variant。 CLng(expression) expression 参数是任意有效的表达式。 说明 通常,您可以使
CInt 函数 返回表达式,此表达式已被转换为 Integer 子类型的 Variant。 CInt(expression) expression 参数是任意有效的表达式。 说明 通常,可
Chr 函数 返回与指定的 ANSI 字符代码相对应的字符。 Chr(charcode) charcode 参数是可以标识字符的数字。 说明 从 0 到 31 的数字表示标准的不可打印的
CDbl 函数 返回表达式,此表达式已被转换为 Double 子类型的 Variant。 CDbl(expression) expression 参数是任意有效的表达式。 说明 通常,您可
CDate 函数 返回表达式,此表达式已被转换为 Date 子类型的 Variant。 CDate(date) date 参数是任意有效的日期表达式。 说明 IsDate 函数用于判断 d
CCur 函数 返回表达式,此表达式已被转换为 Currency 子类型的 Variant。 CCur(expression) expression 参数是任意有效的表达式。 说明 通常,
CByte 函数 返回表达式,此表达式已被转换为 Byte 子类型的 Variant。 CByte(expression) expression 参数是任意有效的表达式。 说明 通常,可以
CBool 函数 返回表达式,此表达式已转换为 Boolean 子类型的 Variant。 CBool(expression) expression 是任意有效的表达式。 说明 如果 ex
Atn 函数 返回数值的反正切值。 Atn(number) number 参数可以是任意有效的数值表达式。 说明 Atn 函数计算直角三角形两个边的比值 (number) 并返回对应角的弧
Asc 函数 返回与字符串的第一个字母对应的 ANSI 字符代码。 Asc(string) string 参数是任意有效的字符串表达式。如果 string 参数未包含字符,则将发生运行时错误。
Array 函数 返回包含数组的 Variant。 Array(arglist) arglist 参数是赋给包含在 Variant 中的数组元素的值的列表(用逗号分隔)。如果没有指定此参数,则
Abs 函数 返回数字的绝对值。 Abs(number) number 参数可以是任意有效的数值表达式。如果 number 包含 Null,则返回 Null;如果是未初始化变量,则返回 0。
FormatPercent 函数 返回表达式,此表达式已被格式化为尾随有 % 符号的百分比(乘以 100 )。 FormatPercent(expression[,NumDigitsAfterD
FormatNumber 函数 返回表达式,此表达式已被格式化为数值。 FormatNumber( expression [,NumDigitsAfterDecimal [,Inc
我是一名优秀的程序员,十分优秀!