• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

mr kglad here i am again, collision and mousemove

Participant ,
Dec 01, 2021 Dec 01, 2021

Copy link to clipboard

Copied

I i try implementing the chiken invaders GUI in my little crappy game, and all went well spachip moves fine, shoots, and kills spaships, but unlike with buttons control, now the hitTest wont execute, unless i clic on the bad spaceship, i try puting it in its own event, switch it to the move event, on top or down of the mousemove code, but execution is the same, if i hover player, over enemy1 nothing happens, unlest i clic on it and then the alert works 😞

 

this.on("tick", moverPlayerMou.bind(this));
function moverPlayerMou(evt) {
var pt = this.enemy1.hit.localToLocal(this.enemy1.hit.dot1.x,
this.enemy1.hit.dot1.y, this.player.box);
if (this.player.box.hitTest(pt.x, pt.y)) {
alert("collision")
this.player.x = -1000
deadenemies++
}
this.player.x = stage.mouseX;
this.player.y = stage.mouseY;
}

 

heres the file 

https://drive.google.com/file/d/1BXvg3b931cB8KKeEjWcmyeVYqUsYwyEF/view?usp=sharing

Views

401

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Dec 04, 2021 Dec 04, 2021

use:

 

this.on("tick", moverPlayerMou.bind(this));
function moverPlayerMou(evt) {
var pt = this.enemy1.localToLocal(this.enemy1.x,
this.enemy1.y, this.player.box);

console.log(pt.x,pt.y);  // and you might want this.enemy1 and this.player.box info
if (this.player.box.hitTest(pt.x, pt.y)) {
alert("collision")
this.player.x = -1000
deadenemies++

}
this.player.x = stage.mouseX;
this.player.y = stage.mouseY;
}

Votes

Translate

Translate
Community Expert , Dec 13, 2021 Dec 13, 2021

i'm not sure what you were/are doing that was so difficult, but this is the basic hittest:

 

createjs.Ticker.on("tick", tick.bind(this));


function tick(event) {
this.arm.rotation += 3;

this.target.alpha = 0.2;
var pt = this.arm.localToLocal(100, 0, this.target);
if (this.target.hitTest(pt.x, pt.y)) {
this.target.alpha = 1;
}

stage.update(event);
}

Votes

Translate

Translate
Community Expert ,
Dec 02, 2021 Dec 02, 2021

Copy link to clipboard

Copied

pt looks suspect.  use console.log to see if you're getting what you expect from localToLocal

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 02, 2021 Dec 02, 2021

Copy link to clipboard

Copied

but, the alert, does execute, i am trying to simplify the path like 

 

this.on("tick", moverPlayerMou.bind(this));
function moverPlayerMou(evt) {
var pt = this.enemy1.localToLocal(this.enemy1.x,
this.enemy1.y, this.player.box);
if (this.player.box.hitTest(pt.x, pt.y)) {
alert("collision")
this.player.x = -1000
deadenemies++

}
this.player.x = stage.mouseX;
this.player.y = stage.mouseY;
}

 

but like this the alert wont work, gonna check the console, why is flash always like this!? 

 

tyvm legendary master flasher!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

use:

 

this.on("tick", moverPlayerMou.bind(this));
function moverPlayerMou(evt) {
var pt = this.enemy1.localToLocal(this.enemy1.x,
this.enemy1.y, this.player.box);

console.log(pt.x,pt.y);  // and you might want this.enemy1 and this.player.box info
if (this.player.box.hitTest(pt.x, pt.y)) {
alert("collision")
this.player.x = -1000
deadenemies++

}
this.player.x = stage.mouseX;
this.player.y = stage.mouseY;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 05, 2021 Dec 05, 2021

Copy link to clipboard

Copied

Thank you Master Mister, always a pleasure learning from you, tyvm!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 05, 2021 Dec 05, 2021

Copy link to clipboard

Copied

you're welcome.

 

p.s. did you solve the problem?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 05, 2021 Dec 05, 2021

Copy link to clipboard

Copied

yea but my problem its to always ask too much from flash, collision executes sometimes, sloppy, and then since the mouse move its active the ship wont go off screen, i try to limit movement with if alive move, but it would freeze, it so i would just go back to good button controls and forget about chiken invaders interface, i am thinking on getting on that godot, they have a lot goin. thanks bro, yes the console show the pt fine, thanks again bud i am cbunbury20 on twitter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

I love flash as you know and been very loyal, but i havc also try other Devs and the collisions are 10 times simple, the EaseJS tutorial of the hitTest its so raquitic and outdated, i could not get it done untill i found one of some latin american guy, I cant believe adobe wont provide a dedicated tutorial just about these, a mario stomping on a koopa, with fla, and, all like in the flashkit, times 😞

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

i'm not sure what you were/are doing that was so difficult, but this is the basic hittest:

 

createjs.Ticker.on("tick", tick.bind(this));


function tick(event) {
this.arm.rotation += 3;

this.target.alpha = 0.2;
var pt = this.arm.localToLocal(100, 0, this.target);
if (this.target.hitTest(pt.x, pt.y)) {
this.target.alpha = 1;
}

stage.update(event);
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

but apes like myself have a hard time scalling things, like i would need a more rock paper scisers, like this is how you kill a spaship, and one .fla, this is how you plataformer jump , i understand more watching things happening, than figure out algorytims, but always huge thanks budd your the best

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

that would take more than a few minutes so is beyond what i would do for free.  if you want to hire me to do that, send me a private message.

 

if you try yourself and encounter problems, you can probably be helped for free via these forums.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

ill thank you a lot, the problem its i do this for hobbie, like DIY, is the last thing i want putting you to work, but in the flashkit times, even flashers.com you could find tutorials for stuff like this for everything, being flash, what was for newsgrounds, its like adobe itself should cover all this, but i just dont understand where are thos tutorials i cant believe that a latin american guy is the only one who did a clear one sort of:

 

https://www.youtube.com/watch?v=ou8jhzXqoIk&t=569s i am shure an American or Russian or Hindu has done a better than this one, i have a long track of doing games with flash, but have fell in a spiderweb with this new hitTest for html5, but you allreaddy help me a lot Kglad, lots of thanks and thank again, man, but if not ill be usefull to some here, i just lived with the notion that flash was the easiest thing to make videogames, but if it is not anymore i guess i am gonnan have to see, 

 

tyvm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines