Hey George, for some reason that shows a error.
import * as ecs from '@8thwall/ecs' // This is how you access the ecs library.
import * as imageTest from './assets/TestingAssets/backone.png'
import buttonclick from './ButtonClick'
const ButtonAction = ecs.registerComponent({
name: 'ButtonAction',
schema: {
// Add data that can be configured on the component.
TestImage: ecs.eid,
},
schemaDefaults: {
// Add defaults for the schema fields.
},
data: {
// Add data that cannot be configured outside of the component.
},
add: (world, component) => {
// Runs when the component is added to the world.
const {TestImage, eid} = component.schema
const entity = TestImage
const clicker = buttonclick.has(world, eid) //doesn't work
console.log(clicker)
world.events.addListener(world.events.globalId, 'buttonPressed', () => handleButtonPressed(world, entity))
},
tick: (world, component) => {
// Runs every frame.
},
remove: (world, component) => {
// Runs when the component is removed from the world.
},
})
“buttonclick.has” is the error and buttonclick has been imported
const buttonclick = ecs.registerComponent({
name: 'ButtonClick',
schema: {
Tstring: ecs.string,
// Add data that can be configured on the component.
},
schemaDefaults: {
// Add defaults for the schema fields.
},
data: {
// Add data that cannot be configured outside of the component.
},
add: (world, component) => {
// Runs when the component is added to the world.
const entity = component.eid
world.events.addListener(entity, 'click', () => ToPressButton(world, entity))
// Store the reference to the Press function on the component data
},
tick: (world, component) => {
// Runs every frame.
},
remove: (world, component) => {
// Runs when the component is removed from the world.
},
})
function ToPressButton(world, entity) {
console.log('Button pressed')
world.events.dispatch(entity, 'buttonPressed')
}
export {ToPressButton, pressed, buttonclick}
I’m not sure why it’s showing the error. My hope is to get a reference to Tstring which has text in the editor. Is there something I’m missing? Thanks!