gifted-whale-78169
12/16/2022, 1:34 AMgifted-whale-78169
12/16/2022, 1:40 AMbillowy-waiter-28954
12/16/2022, 10:41 AMbillowy-waiter-28954
12/16/2022, 10:45 AMgifted-whale-78169
12/16/2022, 11:10 AMgifted-whale-78169
12/16/2022, 7:37 PMhx
initPhysics();
}
function initPhysics() {
app.arcade.onUpdate(this, updatePhysics);
}
function updatePhysics(d: Float) {
trace(plr);
trace(block);
plr.updatePhysics([block]); //!get collisions working
}
but i keep getting an error for the onUpdate
event, saying TypeError: Cannot read property 'enable' of null
gifted-whale-78169
12/16/2022, 7:37 PMgifted-whale-78169
12/16/2022, 7:37 PMbillowy-waiter-28954
12/16/2022, 7:46 PMgifted-whale-78169
12/16/2022, 7:51 PMgifted-whale-78169
12/16/2022, 7:51 PMhx
//player
public function updatePhysics(a:Array<arcade.Collidable>) {
for (v in a) {
app.arcade.world.collide(this, v);
}
gifted-whale-78169
12/16/2022, 7:52 PMhx
//scene
override function create() {
app.arcade.world.gravityY = -90;
block = initBlock("Hellope, worl!");
add(block);
plr = new Player();
plr.depth = 1;
plr.anchor(0.5, 0.5);
plr.pos(width/2, height - 65);
add(plr);
var hint = initHint("I hate", "mice");
add(hint);
app.arcade.onUpdate(this, updatePhysics);
}
function updatePhysics(d: Float) {
plr.updatePhysics([block]);
}
gifted-whale-78169
12/16/2022, 7:53 PMblock
billowy-waiter-28954
12/16/2022, 7:54 PMgifted-whale-78169
12/16/2022, 7:55 PMhx
function initBlock(t:String): Visual {
//begin block and children definition//
block = new Visual();
block.depth = 0; //lets player be shown in front
block.pos(width/2, height/2);
var q = new Quad();
q.size(200, 200);
q.color = Color.WHITE;
q.anchor(0.5, 0.5);
q.initArcadePhysics();
q.body.immovable = true;
q.body.allowGravity = false;
block.add(q);
var txt = new Text();
txt.align = CENTER;
txt.color = Color.BLACK;
txt.content = t;
txt.anchor(0.5, 0.5);
txt.pointSize = 30;
txt.color = Color.CRIMSON;
txt.clip = q; //makes text clip if out of q bounds
block.add(txt);
is the block, i forgot to change the updatePhysics to plr.updatePhysics([block.children[0]]);
gifted-whale-78169
12/16/2022, 7:55 PMgifted-whale-78169
12/16/2022, 7:55 PMelegant-twilight-61392
12/16/2022, 7:58 PMgifted-whale-78169
12/16/2022, 7:59 PMgifted-whale-78169
12/16/2022, 7:59 PMgifted-whale-78169
12/16/2022, 8:00 PMelegant-twilight-61392
12/16/2022, 8:01 PMgifted-whale-78169
12/16/2022, 8:01 PMarcade.onUpdate
eventgifted-whale-78169
12/16/2022, 8:01 PMgifted-whale-78169
12/16/2022, 8:02 PMblock
when it doesnt have the physics initializedgifted-whale-78169
12/16/2022, 8:02 PMq
, but im not sure how to do thatgifted-whale-78169
12/16/2022, 8:02 PMfierce-tiger-85769
12/16/2022, 8:03 PMelegant-twilight-61392
12/16/2022, 8:03 PMgifted-whale-78169
12/16/2022, 8:03 PM