1. Flash ActionScript2.0 ボール横移動
ActionScriptソースコード
2. Flash ActionScript2.0 ボール縦横移動
ActionScriptソースコード
3. Flash ActionScript2.0 ボール縦横移動 掴む離す
ActionScriptソースコード
4. Flash ActionScript2.0 ボール縦横移動 掴む投げる
ActionScriptソースコード
5. Flash ActionScript2.0 ボール 重力、摩擦、跳ね返り係数
ActionScriptソースコード
1. Flash ActionScript2.0 ボール横移動
onClipEvent(load){
speedX = 10;
}
onClipEvent(enterFrame){
if (this._x>500-this._width/2){
speedX = speedX*-1;
}
if (this._x<0+this._width/2){
speedX = speedX*-1;
}
this._x += speedX;
}
2. Flash ActionScript2.0 ボール縦横移動
onClipEvent(load){
speedX = 10;
speedY = 8;
}
onClipEvent(enterFrame){
if (this._x>500-this._width/2){
speedX = speedX*-1;
}
if (this._x<0+this._width/2) {
speedX = speedX*-1;
}
if (this._y>400-this._width/2) {
speedY = speedY*-1;
}
if (this._y<0+this._width/2) {
speedY = speedY*-1;
}
this._x += speedX;
this._y += speedY;
}
3. Flash ActionScript2.0 ボール縦横移動 掴む離す
onClipEvent(load){
speedX = 10;
speedY = 8;
ballHold = 0;
}
onClipEvent(enterFrame){
if(ballHold == 1){
}else{
if (this._x>500-this._width/2){
speedX = speedX*-1;
}
if (this._x<0+this._width/2) {
speedX = speedX*-1;
}
if (this._y>400-this._width/2) {
speedY = speedY*-1;
}
if (this._y<0+this._width/2) {
speedY = speedY*-1;
}
this._x += speedX;
this._y += speedY;
}
}
on (press) {
ballHold = 1;
startDrag(this, true);
}
on (release) {
ballHold = 0;
stopDrag();
}
4. Flash ActionScript2.0 ボール縦横移動 掴む投げる
onClipEvent(load){
speedX = 10;
speedY = 8;
ballHold = 0;
}
onClipEvent(enterFrame){
if(ballHold == 1){
x1 = x2;
y1 = y2;
x2 = this._x;
y2 = this._y;
speedX = (x2-x1);
speedY = (y2-y1);
}else{
if (this._x>500-this._width/2){
this._x = 500-this._width/2;
speedX = speedX*-1;
}
if (this._x<0+this._width/2) {
this._x = 0+this._width/2;
speedX = speedX*-1;
}
if (this._y>400-this._width/2) {
this._y = 400-this._width/2;
speedY = speedY*-1;
}
if (this._y<0+this._width/2) {
this._y = 0+this._width/2;
speedY = speedY*-1;
}
this._x += speedX;
this._y += speedY;
}
}
on (press) {
ballHold = 1;
startDrag(this, true);
}
on (release) {
ballHold = 0;
stopDrag();
}
5. Flash ActionScript2.0 ボール 重力、摩擦、跳ね返り係数
onClipEvent(load){
speedX = 10;
speedY = 8;
ballHold = 0;
}
onClipEvent(enterFrame){
if(ballHold == 1){
x1 = x2;
y1 = y2;
x2 = this._x;
y2 = this._y;
speedX = (x2-x1);
speedY = (y2-y1);
}else{
if (this._x>500-this._width/2){
this._x = 500-this._width/2;
speedX = speedX*-1*0.8;
}
if (this._x<0+this._width/2) {
this._x = 0+this._width/2;
speedX = speedX*-1*0.8;
}
if (this._y>400-this._width/2) {
this._y = 400-this._width/2;
speedY = speedY*-1*0.8;
}
if (this._y<0+this._width/2) {
this._y = 0+this._width/2;
speedY = speedY*-1*0.8;
}
speedX = speedX*0.99;
speedY = speedY*0.99+0.98;
this._x += speedX;
this._y += speedY;
}
}
on (press) {
ballHold = 1;
startDrag(this, true);
}
on (release) {
ballHold = 0;
stopDrag();
}