Tuesday, July 5, 2022
HomeGame DevelopmentWant to assist me with set up of Cocos2dx atmosphere in React...

Want to assist me with set up of Cocos2dx atmosphere in React Native – JavaScript


I’m a more moderen in Cocos2dx JavaScript and I’m gonna make a easy tetris app utilizing React Native + Cocos2dx.
Additionally, I discovered an instance which utilizing ‘npm set up @remobile/react-native-cocos2dx –save’ however it doesn’t work as a result of it couldn’t acknowledge ‘cc.xxx’.
Right here is the pattern code.

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
    StyleSheet,
    View,
} = ReactNative;

var resolveAssetSource = require('resolveAssetSource');
var Cocos2dx = require('@remobile/react-native-cocos2dx');

module.exports = React.createClass({
    renderCocos2dx() {
        return (res, transProps)=> {
            cc.sport.onStart = perform(){
                var MyScene = cc.Scene.lengthen({
                    alert(transProps.textual content);
                    onEnter:perform () {
                        this._super();
                        var measurement = cc.director.getWinSize();

                        var sprite = cc.Sprite.create(res.img.qq);
                        sprite.setPosition(measurement.width / 2, measurement.peak / 2 - 200);
                        sprite.setScale(0.8);
                        this.addChild(sprite, 0);

                        var sprite = cc.Sprite.create(res.img.weixin);
                        sprite.setPosition(measurement.width / 2, measurement.peak / 2);
                        sprite.setScale(0.8);
                        this.addChild(sprite, 0);

                        var label = cc.LabelTTF.create("Whats up World", "Arial", 40);
                        label.setPosition(measurement.width / 2, measurement.peak / 2 + 200);
                        label.setColor(255, 0,255);
                        this.addChild(label, 1);
                    }
                });
                cc.director.runScene(new MyScene());
            };
            cc.sport.run();
        }
    },
    render () {
        const useful resource = {
            img: {
                qq: resolveAssetSource(require('./img/qq.img')).uri,
                weixin: resolveAssetSource(require('./img/weixin.img')).uri,
            }
        };
        return (
            <View model={kinds.container}>
                <Cocos2dx
                    render={this.renderCocos2dx()}
                    useful resource={useful resource}
                    transProps={{textual content: 'I'm from react-native'}}
                    width={sr.tw}
                    peak={sr.tch}
                    />
            </View>
        );
    },
});

var kinds = StyleSheet.create({
    container: {
        flex: 1
    },
});

Wanting ahead to get a solution asap.
Thanks.


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments