Replies: 1 comment
-
Hi @Charkui I have the full sample posted here to compare. With the Hope this helps, Erik |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all!
My doubt is this: It's there a way that an Fixed-collision actor doesn't collide with a passive one? I was following the getting-started tutorial but... from the excitement for learn how to create videogames, I decided to jump directly to use the wepack template, that defines a Game class that extends Engine, I was following the instructions and trying to make it modular at the same time. But when I finished the ball Actor segment from the tutorial. The ball wasn't colliding with the paddle.
The files are the next:
paddle.ts
`import {Actor, CollisionType, Color} from 'excalibur'
export default class Paddle extends Actor {
constructor(gameHeight: number){
super({
x: 150,
y: gameHeight - 40,
width: 200,
height: 20,
color: Color.Chartreuse
})
this.body.collider.type = CollisionType.Fixed;
}
}
`
ball.ts
`import {Actor, CollisionType, Color} from 'excalibur'
export default class Ball extends Actor {
constructor(posX: number, posY: number){
super({
x: posX,
y: posY,
color: Color.Red
})
}`
game.ts
`import { Engine, Loader, DisplayMode, vec } from 'excalibur';
import { LevelOne } from './scenes/level-one/level-one';
import Paddle from './actors/player/paddle';
import Ball from './actors/ball/ball';
import { Resources } from './resources';
/**
*/
class Game extends Engine {
private paddle: Paddle;
private ball: Ball;
private levelOne: LevelOne;
constructor() {
super({ displayMode: DisplayMode.FullScreen });
}
public start() {
}
private configureBall() {
this.ball.on('postupdate', () => {
if(this.ball.pos.x < this.ball.width / 2){
this.ball.vel.x *= -1;
}
}
private setBallVelocity(){
this.ball.vel = vec(100,100);
}
}
const game = new Game();
game.start().then(() => {
game.goToScene('levelOne');
});
`
level-one.ts
`import { Engine, Scene } from 'excalibur';
/**
*/
export class LevelOne extends Scene {
public onInitialize(engine: Engine) {}
public onActivate() {}
public onDeactivate() {}
}
`
Thanks for your time, I'm really enjoying excalibur and the tutorial!
Beta Was this translation helpful? Give feedback.
All reactions