Sensing

Touching

Touching Sprite

isTouching()
// add sprite variables "ball_sprite" and "paddle_sprite" in the "Sprites TAB"

ball_sprite.whenFlag(function () {                                  
    
    ball_sprite.pointInDirection(180)
    ball_sprite.goTo(0,150)
    
    while(true){                                                   
        ball_sprite.ifOnEdgeBounce()
        ball_sprite.move(10)
        if (ball_sprite.isTouching(paddle_sprite)) {
            ball_sprite.say ('touching paddle')
        } else {
            ball_sprite.say('not touching paddle')
        }
    }       
})

Touching Backdrop Colour

Doesn't work YET
// Example: isTouchingBackdropColor
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-1)
        console.log(this.touchingBackdropColour())
        if (this.isTouchingBackdropColor('#653B00')) {
            this.say ('touching brown colour with HEX code #653B00')
        } else {
            this.say('not touching brown colour ')
        }
    }       
})

Touching Edge

isTouchingEdge()
// 'bottom', 'top', 'left' or 'right'
// Example: isTouchingEdge 'bottom', 'top', 'left' or 'right'
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-2)
        if (this.isTouchingEdge('bottom')) {
            this.say ('touching bottom edge')
        } else {
            this.say('not touching bottom edge')
        }
    }       
})

Distance To

Distance to mouse-pointer

isTouchingEdge()
// 'bottom', 'top', 'left' or 'right'
// Example: isTouchingEdge 'bottom', 'top', 'left' or 'right'
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-2)
        if (this.isTouchingEdge('bottom')) {
            this.say ('touching bottom edge')
        } else {
            this.say('not touching bottom edge')
        }
    }       
})

Distance to Sprite

isTouchingEdge()
// 'bottom', 'top', 'left' or 'right'
// Example: isTouchingEdge 'bottom', 'top', 'left' or 'right'
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-2)
        if (this.isTouchingEdge('bottom')) {
            this.say ('touching bottom edge')
        } else {
            this.say('not touching bottom edge')
        }
    }       
})

Ask & Answer

isTouchingEdge()
// 'bottom', 'top', 'left' or 'right'
// Example: isTouchingEdge 'bottom', 'top', 'left' or 'right'
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-2)
        if (this.isTouchingEdge('bottom')) {
            this.say ('touching bottom edge')
        } else {
            this.say('not touching bottom edge')
        }
    }       
})

Key Pressed?

isTouchingEdge()
// 'bottom', 'top', 'left' or 'right'
// Example: isTouchingEdge 'bottom', 'top', 'left' or 'right'
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-2)
        if (this.isTouchingEdge('bottom')) {
            this.say ('touching bottom edge')
        } else {
            this.say('not touching bottom edge')
        }
    }       
})

Mouse Down?

isTouchingEdge()
// 'bottom', 'top', 'left' or 'right'
// Example: isTouchingEdge 'bottom', 'top', 'left' or 'right'
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-2)
        if (this.isTouchingEdge('bottom')) {
            this.say ('touching bottom edge')
        } else {
            this.say('not touching bottom edge')
        }
    }       
})

Mouse XY?

isTouchingEdge()
// 'bottom', 'top', 'left' or 'right'
// Example: isTouchingEdge 'bottom', 'top', 'left' or 'right'
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-2)
        if (this.isTouchingEdge('bottom')) {
            this.say ('touching bottom edge')
        } else {
            this.say('not touching bottom edge')
        }
    }       
})

Timer & Reset Timer

isTouchingEdge()
// 'bottom', 'top', 'left' or 'right'
// Example: isTouchingEdge 'bottom', 'top', 'left' or 'right'
exampleSprite_sprite.whenFlag(function () {
        
    while(true){                                                   
        this.changeY(-2)
        if (this.isTouchingEdge('bottom')) {
            this.say ('touching bottom edge')
        } else {
            this.say('not touching bottom edge')
        }
    }       
})