Quantcast
Channel: Cocos Forums - Latest topics
Viewing all 17057 articles
Browse latest View live

How to Get LocalTime and Timezone

$
0
0

@WappnotechDevloper wrote:

hello there,
i am developing an android game in which i change background as per time,
means if a player plays game during daytime then it will show light background, and if they play during night time then it will show dark background.

anyone knows how can i do that.
thank you in advance

Posts: 2

Participants: 2

Read full topic


How to use sqlite in cocos creator?

Article: We answer some of your questions about WeChat Mini Games

Help! Failed login

[Squally] We're open sourcing our cocos2d-x game!

$
0
0

@zcanann wrote:

Hey everyone! We’ve been developing our game with cocos2d-x for about a year now. Squally is a 2D platformer JRPG designed to teach low-level computer science.

The repository can be found here: https://github.com/Squalr/Squally
The steam page can be found here: https://store.steampowered.com/app/770200/Squally/

We have successfully launched it on Steam as early-access, and the game is still in active development. Now we’re trying to give back to the community by sharing our code and giving people a solid example of what they can do with cocos2d-x.

We’re currently using a forked version of cocos2d-x 3.17. In an effort to move quickly, none of our changes ever made it back to cocos. We’re hoping that moving forward we can rebase our game onto the latest engine, and let these two projects grow together.

Cheers,
Zac

Posts: 2

Participants: 2

Read full topic

[Feature Request] Lock Widget component

$
0
0

@RealChaoz wrote:

It’s super annoying when working with a Node with the Widget component and you have to re-type the top/left/right/bottom values in the Widget component every time you change the slightest bit of that component. For example, a Label (with Widget and left = 0) in a Layout. Every time you change the text, it’s width changes and, instead of moving the Label to the right, it changes the Widget left value.

It would be really useful if the Widget component could be ‘locked’, as in, when the component is resized, instead of the borders changing, it would be moved so the borders remain the same.

Posts: 1

Participants: 1

Read full topic

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

$
0
0

@rollingpandaarts wrote:

pid: 0, tid: 0 >>> bundleID <<<

backtrace:
#00 pc 0000000000000004
#01 pc 000000000018d41b /system/lib/libwebviewchromium.so
#02 pc 0000000000194521 /system/lib/libwebviewchromium.so
#03 pc 000000000001dd8c /system/lib/libdvm.so (dvmPlatformInvoke+112)
#04 pc 000000000004e283 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#05 pc 00000000000271a0 /system/lib/libdvm.so
#06 pc 000000000002e17c /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#07 pc 000000000002b828 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#08 pc 0000000000060b55 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+392)
#09 pc 0000000000068af7 /system/lib/libdvm.so
#10 pc 00000000000271a0 /system/lib/libdvm.so
#11 pc 000000000002e17c /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#12 pc 000000000002b828 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#13 pc 0000000000060873 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+338)
#14 pc 0000000000049e6b /system/lib/libdvm.so
#15 pc 0000000000051d0f /system/lib/libandroid_runtime.so
#16 pc 0000000000053607 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*, bool)+358)
#17 pc 0000000000001063 /system/bin/app_process
#18 pc 000000000000e463 /system/lib/libc.so (__libc_init+50)
#19 pc 0000000000000d80 /system/bin/app_process

Device :Galaxy Tab3 Lite 7.0
Andoid 4.4

Posts: 1

Participants: 1

Read full topic

Creating a texture dynamically

$
0
0

@xerosugar wrote:

I want to be able to pick multiple tiles from my tilesheet and “stamp” them onto a new texture which will become a sprite. I can do it once, but when I try to do it a second time the first stamp is erased from the texture. The plan is to do all of this in a loop when it’s done (things are hardcoded right now).

Or should is it better (or faster) to manipulate the texture data as discussed here?
Is it possible to "erase" some pixels from a sprite?

Here’s the code code I’ve been testing with:

// src is a sprite
Rect rectStart = Rect((colStart * TILE_SIZE) + offset.x, (rowStart * TILE_SIZE + offset.y), 16, 16);
auto texture = RenderTexture::create(w, h, src->getTexture()->getPixelFormat());
auto stamp = RenderTexture::create(16, 16, src->getTexture()->getPixelFormat());

stamp->clear(0, 0, 0, 0);
stamp->begin();
src->setFlipY(true);
src->setPosition(-rectStart.origin.x, -rectStart.origin.y);
src->visit();
stamp->end();

texture->clear(1.0f, 0, 0, 1.0f);
texture->begin();
stamp->setPosition(8, 8);
stamp->visit(Director::getInstance()->getRenderer(), this->getParentToNodeTransform(), FLAGS_TRANSFORM_DIRTY);
texture->end();

Rect rectEnd = Rect((colMid * TILE_SIZE) + offset.x, (rowMid * TILE_SIZE + offset.y), 16, 16);
	
stamp->clear(0, 0, 0, 0);
stamp->begin();
src->setPosition(-rectEnd.origin.x, -rectEnd.origin.y);
src->visit();
stamp->end();

texture->begin();
stamp->setPosition(24, 8);
stamp->visit(Director::getInstance()->getRenderer(), this->getParentToNodeTransform(), FLAGS_TRANSFORM_DIRTY);
texture->end();

Posts: 1

Participants: 1

Read full topic


Particle System Position Type Bug (CC 2.1.2)

$
0
0

@MercuryBD wrote:

Something is wrong with particle system position type when I upgraded project to CC 2.1.2.

Position type mode FREE is not working correctly, particles fly all around, tested it on an empty project it’s the same. The particle should retain the same properties as in picture 1 but can move freely in space, but it starts shouting particles all around (think it’s because of tangential and radial acceleration properties).

Also for some reason, all the particles that were created to use free position type, switched to relative when I clicked on custom checkbox in the editor to check properties.

For test use the default atom particle and set the position type to FREE. You can check how particles behaved in CC 2.1.0 and in CC 2.1.2, I upgraded from 2.1.0 to 2.1.2 :slight_smile:

@jare @slackmoehrle

Also if it’s not an easy fix for cocos, is there an easy way to downgrade project back to 2.1.0 so I don’t have these problems?

Thanks in advance. :wink:

Posts: 2

Participants: 2

Read full topic

How to Implement SoftMask with ScrollView

What action is best effect for earthquake

$
0
0

@aqwer4 wrote:

hi guys. now i create screen effect earthquake
and i used action to background’s node => bgNode.runAction(cc.jumpTo(duration, 0, 0, gap, shakeCount).easing(cc.ease~~()));

i tried to various “easing”, and change the value(duration, gap, shakecount) .

but it’s not look so earthquake. it’s… something is wrong!
feel so different.

so anyone have good idea?

ps) i’ve tried to “moveTo” And runAction(sequence(actionA,actionB …)) but i want to simple it

Posts: 2

Participants: 2

Read full topic

Is SDKBOX dead?

$
0
0

@pccsoares wrote:

Many SDKBOX plugins stopped being updated for a long time. The last post for SDKBOX in this forum is 8 months old. Is there a change you guys release the source code so we can update the old plugins to the newer versions?
Example: the appodeal plugin is importing Appodeal SDK from 2 years ago. That version of appodeal is not Google compliant anymore. I will have to rewrite the sdkbox appodeal plugin source from scratch, to make it work with the newest version of appodeal sdk.

Posts: 4

Participants: 2

Read full topic

Is there any way to achieve Z Ordering on more than just

$
0
0

@RealChaoz wrote:

I’m trying to create a dropdown button. The concept is pretty simple - a normal button that has a child that is set to be visible when the button is pressed. This dropdown button is part of a Settings dialog (vertical top-to-bottom in this case). The desired outcome here is that the dropdown part that appears should be rendered on top of things that are below it. Since the rendering happens top-to-bottom (in the hierarchy), the outcome is obviously different:


Is there any way to make the ‘English’ button (which is a child of the ‘Language’ button) appear on top of the credits button? This is the hierarchy:
Screenshot_41

Posts: 2

Participants: 2

Read full topic

Dragon Bones bug with LOOP_COMPLETE EVENT (CC 2.1.2)

$
0
0

@MercuryBD wrote:

I switched from CC 2.1.0 to CC 2.1.2 and I get this animation bug with Dragon Bones animation. When I set the event to get when LOOP_COMPLETE event is completed then I switch animation to some other one and everything was okay in CC 2.1.0, but in 2.1.2 I get a glitch (only on native mobile IOS/Android, in web version it’s fine) when loop_complete is called one second later than it should so the animation switch happens second later.

Example:

cc.Class({
    extends: cc.Component,

    // giftAnimation dragon bone animation is set to play 'enter' animation on load in inspector

    properties: {
        giftAnimation: dragonBones.ArmatureDisplay  // DragonBones Asset
    },

    onLoad: function()
        this.giftAnimation.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.animationEventHandler, this);
    }

    animationEventHandler: function (event) {

        if (event.type === dragonBones.EventObject.LOOP_COMPLETE) {
            // This plays some time later, so I get a little of beggining enter animation before it switches to idle that should play 
            if (event.animationState.name === "enter") {
                this.giftAnimation.playAnimation('idle', -1);
            }
        }
    }
}

This happens in 2 projects of my that I upgraded to CC 2.1.2, was there any change on Dragon Bones API?

Thanks in advance.

@jare @Big_Bear @slackmoehrle

Posts: 1

Participants: 1

Read full topic

Generate App Bundle (Google Play) not completed

$
0
0

@binhpv wrote:

I build android app with App Bundle with cocos creator 2.1.1 but:

When finished build .apk file

  • Cocos creator log BUILD SUCCESS. And apk has been moved to /build/jsb-default/publish/android/

  • in Cocos creator log “Begin generate App Bundle…” and never set “complie completed” status, but .abb file generated to /build/jsb-default/frameworks/runtime-src/proj.android-studio/app/build/outputs/bundle/release and not move to /build/jsb-default/publish/android/

I using Android SDK Tools as below:

Can anyone help me?

Posts: 1

Participants: 1

Read full topic


Tutorial: Creating a Super Mario style game in Cocos Creator

$
0
0

@slackmoehrle wrote:

Super Mario in Cocos Creator

This tutorial demonstrates how to quickly and flexibly use Cocos Creator to design the Super Mario classic game. Do you remember it?

Prerequisites

Please review the following documentation:

This tutorial is based on the Cocos Creator v2.x version. If you don’t yet have Cocos Creator you can Download and install it.

Getting started

Let’s take a look at the effects we want to achieve (all art resources come from the Internet).

Game Scene Design

Referring to Super Mario’s worldview, we build our world node tree in Node Manager first, add a Camera object, background layer, world root, map, and a player (role) node.

Add the Main Camera

A Camera acts as a window for the player to observe the game world. By default, Cocos Creator automatically assigns a camera to the Scene, this means we don’t need to add one manually.

Add a Main Root Node

We need to setup a few items and scripts to get our game naded in the right direction. Let’s perform the following actions:

  1. Add an empty Node and rename it to World Root. World Root will act as our main container for adding object nodes in the game.

  2. Create the script, world.ts and drag it into the Node Properties Panel. Next, configure the game world parameters, such as setting the value of the gravitational acceleration G. Here is some example code:

    // world.ts
    const {ccclass, property} = cc._decorator;
    
    @ccclass
    export default class CWorld extends cc.Component {
    
        @property()
        WorldFallG: number = 0;    
    
        @property() 
        WorldWalkA: number = 0;
    
        static G: number = 0;    
        static WalkA: number = 0; 
        
        // LIFE-CYCLE CALLBACKS:
    
        onLoad () {
            CWorld.G = this.WorldFallG;    
            CWorld.WalkA = this.WorldWalkA; 
        }
    
        start () {
            // enable Collision System
            cc.director.getCollisionManager().enabled = true;
            cc.director.getCollisionManager().enabledDebugDraw = true;
            cc.director.getCollisionManager().enabledDrawBoundingBox = true;
        }
    
        // update (dt) {}
    }
    
  3. Create the script lookat.ts and drag it into the Node Properties Panel to synchronize the world perspective based on the location of the Player Node. Here is some example code:

    // lookat.ts
    const { ccclass, property } = cc._decorator;
    
    @ccclass
    export default class NewClass extends cc.Component {
    
        @property(cc.Node)
        target: cc.Node = null;
    
        @property(cc.Node)
        map: cc.Node = null;
    
        boundingBox: cc.Rect = null;
        screenMiddle: cc.Vec2 = null;
    
        minX: number = 0;
        maxX: number = 0;
        minY: number = 0;
        maxY: number = 0;
    
        isRun: boolean = true;
    
        // LIFE-CYCLE CALLBACKS:
    
        onLoad() {
            this.boundingBox = new cc.Rect(0, 0, this.map.width, this.map.height);
            let winsize = cc.winSize;
            this.screenMiddle = new cc.Vec2(winsize.width / 2, winsize.height / 2);
            this.minX = -(this.boundingBox.xMax - winsize.width);
            this.maxX = this.boundingBox.xMin;
            this.minY = -(this.boundingBox.yMax - winsize.height);
            this.maxY = this.boundingBox.yMin;
        }
    
        update() {
            if (!this.isRun) 
                return;
                
            let pos = this.node.convertToWorldSpaceAR(cc.Vec2.ZERO);
            let targertPos = this.target.convertToWorldSpaceAR(cc.Vec2.ZERO);
            let dis = pos.sub(targertPos);
            let dest = this.screenMiddle.add(dis);
            dest.x = cc.misc.clampf(dest.x, this.minX, this.maxX);
            dest.y = this.minY;
            this.node.position = this.node.parent.convertToNodeSpaceAR(dest);
        }
    }
    

Adding a role (Player)

The Player node, is the focus of the game world perspective and we will control it to do what we want.

Adding a map (Tiled Map)

The map resource, _level01 is created by Tiled. Cocos Creator supports TiledMap v1.0. Drag level01 into the World Root node. The map node will be generated automatically. You can view map levels by expanding the TiledMap.

We need to instantiate the TiledMap. We can create worldmap.ts script to do the work. The following figure shows the Prefab resources binding for the map level objects we have configured in Tiled.

The instantiation of a map object is divided into several steps:

  • Prefab resources corresponding to the instantiation type
  • Set up a collision group
  • Set the object size
  • Add collision components
  • Set the type tag of the object

In worldmap.ts, the instantiation of a water object is as follows:

// worldmap.ts
// get waters layer and traverse all water objects.
var waters = this.worldMap.getObjectGroup(this.waterLayerName);
for (var i = 1; i < 8; i++) {
  var waterName = 'water' + i;
  var waterBlock = waters.getObject(waterName);
  var waterNode = cc.instantiate(this.ColliderPreName);

  // set group name for Collider System.
  waterNode.group = 'water';
  
  // set size
  waterNode.width = waterBlock.width;
  waterNode.height = waterBlock.height;
  waterNode.x = waterBlock.x;
  waterNode.y = waterBlock.y - waterBlock.height;
  
  // add collider component.
  waterNode.addComponent(cc.BoxCollider);
  waterNode.getComponent(cc.BoxCollider).size = cc.size(waterNode.width, waterNode.height);
  waterNode.getComponent(cc.BoxCollider).offset = 
    new cc.Vec2(waterNode.width / 2, -waterNode.height / 2);

  // set tag for check when collision. 
  waterNode.getComponent(cc.BoxCollider).tag = 6;
  this.node.addChild(waterNode);
}

Adding collision rules

World objects contain characters, ground, squares, gold coins, beetles, water, mushrooms and more. But how do we respond to interactions between these objects? It’s easy, we need to create collision groups to help constrain the collision rules between all the types of objects we have in our game.

Game Object Design

The game objects are categorized into Prefab objects, according to their own characteristics. Our Prefab object will add the following characteristics to our objects:

  • Collision
  • Animation
  • Sound
  • Behavior

Object Prefab production

For example, here is the Beetle’s resource directory, which contains the Beetle animation file beetle_anim, the Prefab resource beetle_node, the skin file beetle_skin, the behavior control script beetle_script.

image-20190731170101522

Add an Action Components to the beetle Prefab:

Add a Collision Component to the beetle Prefab:

Add a Script Component to the Beetle Prefab to set the speed, zoom factor, sound effects, etc.

Here is what the beetle Script Component, mentioned above, might look like to achieve collision detection and behavior control. Example:

const { ccclass, property } = cc._decorator;

@ccclass
export default class enemy extends cc.Component {
    @property()
    speed: cc.Vec2 = new cc.Vec2(0, 0);

    @property
    scaleX: number = 1;

    @property
    canMove: boolean = true;

    @property({type: cc.AudioClip})
    dieAudio: cc.AudioClip = null;

    anim: cc.Animation = null;

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        this.node.scaleX = 1;
        this.anim = this.getComponent(cc.Animation);
    }

    start() {

    }

    // onCollisionEnter overrated
    onCollisionEnter(other, self) {
        if (other.tag == 5) {
            this.turn();
            this.speed.x = -this.speed.x;
        }

        var otherAabb = other.world.aabb;
        var otherPreAabb = other.world.preAabb.clone();

        var selfAabb = self.world.aabb;
        var selfPreAabb = self.world.preAabb.clone();
        selfPreAabb.y = selfAabb.y;
        otherPreAabb.y = otherAabb.y;

        if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
            if (selfPreAabb.yMax < otherPreAabb.yMax && other.node.group == 'player') {
                this.todie();
            }
        }
    }

    todie() {
        cc.audioEngine.play(this.dieAudio, false, 1);
        this.anim.play('beetled');
        this.canMove = false;
        this.node.height = this.node.height * 0.3;
      
        this.node.runAction(cc.fadeOut(.5));
        this.scheduleOnce(function () {
            this.node.removeFromParent();
        }, 0.5);
    }

    update(dt) {
        if (this.canMove) {
            this.node.x -= this.speed.x * dt;
        }
    }

    turn() {
        this.node.scaleX = -this.node.scaleX;
    }
}

Player (Role) Logic Design

As the core of the game, the Player’s (role) design is more complicated, mainly divided into two parts: control events and collision events. We need both of these items in-order to achieve our goals. Let’s add each one to our beetle Script Component that we have been using from above:

Control event handling

Here is an example of how we might want to control event handling:

onLoad() {
  cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
  cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
}

onDestroy() {
  cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
  cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
}

onKeyDown(event) {
  switch (event.keyCode) {
    case cc.macro.KEY.a:
    case cc.macro.KEY.left:
      this.playerLeft();
      break;
    case cc.macro.KEY.d:
    case cc.macro.KEY.right:
      this.playerRight();
      break;
    case cc.macro.KEY.w:
    case cc.macro.KEY.up:
      this.playerUp();
      break;
    case cc.macro.KEY.down:
    case cc.macro.KEY.s:
      this.playerDown();
      break;
  }
}

onKeyUp(event) {
  switch (event.keyCode) {

    case cc.macro.KEY.a:
    case cc.macro.KEY.left:
    case cc.macro.KEY.d:
    case cc.macro.KEY.right:
      this.noLRControlPlayer();
      break;
    case cc.macro.KEY.up:
    case cc.macro.KEY.w:
      this.noUpControlPlayer();
      break;
    case cc.macro.KEY.s:
    case cc.macro.KEY.down:
      this.noDownControlPlayer();
      break;
  }
}

Collision event processing

The object is assigned an object type tag when instantiated, and the following code assigns different collision logic based on the tag.

onCollisionEnter(other, self) {
   if (this.touchingNumber == 0) {
     if (this.buttonIsPressed)
       this.player_walk();
     else
       this.player_idle();
   }
   switch (other.tag) {
     case 1://coin.tag = 1
       this.collisionCoinEnter(other, self);
       break;
     case 2://bonusblock6.tag = 2
     case 3://breakableWall = 3
     case 7: //bonusblock6withMushroom.tag = 7
       this.collisionBonusWallEnter(other, self);
       break;
     case 4://enemy.tag = 4
       this.collisionEnemyEnter(other, self);
       break;
     case 5://platform.tag = 5
       this.collisionPlatformEnter(other, self);
       break;
     case 6://water.tag = 6
       this.collisionWaterEnter(other, self);
       break;
     case 8://mushroom.tag = 8
       this.collisionMushroomEnter(other, self);
       break;
   }
 }

We also need to handle collision events between the character and the ground. This might look like the following:

collisionPlatformEnter(other, self) {
  this.touchingNumber++;
  this.jumpCount = 0;
  var otherAabb = other.world.aabb;
  var otherPreAabb = other.world.preAabb.clone();
  var selfAabb = self.world.aabb;
  var selfPreAabb = self.world.preAabb.clone();
  selfPreAabb.x = selfAabb.x;
  otherPreAabb.x = otherAabb.x;

  if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {

    if (this._speed.x < 0 && (selfPreAabb.xMax > otherPreAabb.xMax)) {
      this.node.x += Math.floor(Math.abs(otherAabb.xMax - selfAabb.xMin));
      this.collisionX = -1;
    }
    else if (this._speed.x > 0 && (selfPreAabb.xMin < otherPreAabb.xMin)) {
      this.node.x -= Math.floor(Math.abs(otherAabb.xMin - selfAabb.xMax));
      this.collisionX = 1;
    } else if (this._speed.x == 0 && (selfPreAabb.xMax == otherPreAabb.xMin)) {
      this.isFallDown = true;
    }

    this._speed.x = 0;
    other.touchingX = true;
    return;
  }
  selfPreAabb.y = selfAabb.y;
  otherPreAabb.y = otherAabb.y;

  if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
    if (this._speed.y < 0 && (selfPreAabb.yMax > otherPreAabb.yMax)) {
      this.node.y = otherPreAabb.yMax - this.node.parent.y;
      this.isJumping = false;
      this.collisionY = -1;
    }
    else if (this._speed.y > 0 && (selfPreAabb.yMin < otherPreAabb.yMin)) {
      cc.audioEngine.play(this.hit_block_Audio, false, 1);
      this.node.y = otherPreAabb.yMin - selfPreAabb.height - this.node.parent.y;
      this.collisionY = 1;
    }

    this._speed.y = 0;
    other.touchingY = true;
  }
  this.isWallCollisionCount++;
}

Next, let’s handle collisions between characters and enemies:

collisionEnemyEnter(other, self) {
  // 1st step
  // get pre aabb, go back before collision
  var otherAabb = other.world.aabb;
  var otherPreAabb = other.world.preAabb.clone();

  var selfAabb = self.world.aabb;
  var selfPreAabb = self.world.preAabb.clone();

  // 2nd step
  // forward x-axis, check whether collision on x-axis
  selfPreAabb.x = selfAabb.x;
  otherPreAabb.x = otherAabb.x;
  if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
    if (this._life == 2) {
      cc.audioEngine.play(this.player_decrease_Audio, false, 1);
      var actionBy = cc.scaleBy(1, 3 / 5);
      this.node.runAction(actionBy);
      this._life--;
    } else if (this._life == 1) {
      this.anim.play("player_die");
      this.rabbitDieJump();
      this.OverNodeLoad();
      return;
    }

    if (this._speed.x < 0 && (selfPreAabb.xMax > otherPreAabb.xMax)) {
      this.node.x += Math.floor(Math.abs(otherAabb.xMax - selfAabb.xMin));
      this.collisionX = -1;
    }
    else if (this._speed.x > 0 && (selfPreAabb.xMin < otherPreAabb.xMin)) {
      this.node.x -= Math.floor(Math.abs(otherAabb.xMin - selfAabb.xMax));
      this.collisionX = 1;
    }

    this._speed.x = 0;
    other.touchingX = true;
    return;
  }

  // 3rd step
  // forward y-axis, check whether collision on y-axis
  selfPreAabb.y = selfAabb.y;
  otherPreAabb.y = otherAabb.y;

  if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
    if (this._speed.y < 0 && (selfPreAabb.yMax > otherPreAabb.yMax)) {
      this.rabbitJump();
      return;
    }
    
    if (this._speed.y > 0 && (selfPreAabb.yMax < otherPreAabb.yMax)) {
      if (this._life == 2) {
        var actionBy = cc.scaleBy(1, 3 / 5);
        this.node.runAction(actionBy);
        this._life--;
      } else if (this._life == 1) {
        this.anim.play("player_die");
        this.rabbitDieJump();
        this.OverNodeLoad();
        return;
      }
    }
    
    this._speed.y = 0;
    other.touchingY = true;
  }
  this.isWallCollisionCount++;
}

Conclusion

We hope that you have enjoyed this tutorial. Remember the goal is to help get you comfortable using Cocos Creator to create a landscape game, using componentization, reducing the amount of code needed and helping you become efficient when using Cocos Creator. The code for this tutorial can be found on GitHub. This code is intended for educational purposes and not deemed for commercial use.

Posts: 1

Participants: 1

Read full topic

Build on android in portrait shows landscape layout

$
0
0

@ivarsbergs wrote:

Screenshot_2019-08-21-10-30-23

Hi, I am having a problem that on android portrait view it renders as it was landscape. In simulator works as expected, fills the whole screen. Tested on 2x Phones/OS versions. Could someone please give me a hint what am I doing wrong?

Posts: 1

Participants: 1

Read full topic

Cocos Creator 2019 Roadmap (updated August 2019)

$
0
0

@slackmoehrle wrote:

The whole team is working hard to bring you amazing versions of Cocos Creator. I’ve recently seen upcoming products and I was blown away. The future looks amazing.

As part of this we revived the public Trello roadmap! It is not easy for developers to see what is planned for future versions and approximately when to expect these versions.

Please take a look: https://trello.com/b/JWVRRxMG

Posts: 2

Participants: 1

Read full topic

Cocos Creator v2.1.3 Beta Release (Aug 21 updated alpha.3)

$
0
0

@jare wrote:

Six months has passed since the release of Cocos Creator v2.1.0, and the team has been hard at work creating the next releases.Cocos Creator v2.1.0 is our most popular release to date. The development teams effort will be spent on Cocos Creator v2.1.0 and therefore maintenance of v2.0.x will be discontinued. v2.0.x users should consider upgrading to v2.1.3 when it makes sense to do so.

v2.1.3 includes general experience improvements and bug fixes, and is recommended for all v2.0 and v2.1 developers . To ensure that this version can better serve your project, it is recommended that all projects that are ready to be upgraded to 2.1.3 be tried in advance.

!! Please take a backup of your work before upgrading !!

Release Notes

Improvements

  • Add fault tolerance for the component’s onLoad, start, update, lateUpdate functions to better handle exceptions thrown by user scripts [#4941]
  • When you preview particles in the editor, the particles in the child nodes under the current node are played simultaneously for easy art viewing
  • Allow double-click on the json asset in Assets panel
  • Add Vec4 type support to Properties panel
  • Upgrade V8 to 7.5 on Android
  • VideoPlayer is available for WeChat Mini Game

Editor

  • Fixed an issue that rotation data in AnimationClip will lost after upgrading from v2.0
  • Fixed an issue when upgrading from v2.0, nodes at a specific angle will lost their rotation
  • Fixed an issue where some machines open projects stop at the “Importing assets, please wait…” interface. (This fix will take effect in rc or official version)
  • Fixed an issue where script may be misreported after it is moved or renamed
  • Fixed an issue where the Timeline editor can’t set Node’s z value
  • Fixed an issue where the gizmo is not located correctly in the scene editor
  • Fixed the problem where node rotation can not undo
  • Fixed an issue where RichText or Label components may generate a space at the beginning of a line when the text filled in in the editor is wrapped
  • Fixed an issue where content is not display when the NodeTree and Assets merge into the same panel

Engine

  • Fixed an issue where a scene async loading assets can cause the 3D model can not be displayed [#5071]
  • Fixed an issue loading a scene with WebView, then the first frame will flash on screen after the scene is switched [#5106]
  • Fixed an issue when a Label used with a LabelOutline, Label’s Overflow is set to SHRINK or CLAMP, and CacheMode is set to CHAR, the node is not sized correctly [#5145]
  • Fixed an issue where RichText may lose spaces after wrapping [#5116]
  • Fixed an issue where the Sprite component does not support MESH mode [#5195]
  • Fixed an issue where ScrollView, PageView enables Elastic may not bounce back after sliding beyond the boundary [#4894]
  • Fixed an issue where Layout doesn’t work correctly when it’s scaling less than 1 [#5074]
  • Fixed an issue that the node where the PhysicsCollider is located may report error by modifying the node’s group property in runtime (thanks to HengHuH) [#4949]
  • Fixed an issue where the engine’s built-in assets may have been mistakenly released by the user [#4915]
  • Fixed an issue where memory leaks can occur when a large number of render nodes are added and deleted [#5025]
  • Fixed node’s targetOff method may not work [#5052]
  • Fixed an issue where an audio instance may have been destroyed by error after more than 32 audio instances are playing at the same time [#5097]

Native

  • Fixed Label memory leaks on native platforms [#1783] [#1786]
  • Fixed an issue where the EditBox font defaults to white on some Android models [#1778]
  • Fixed issues where EditBox characters is overlapping in input state on Mac and Windows [#146]
  • Fixed an issue where EditBox input emoji on iOS may crash [#1798]
  • Fixed an audio bug on Android that audios are not paused when locking screen while notification drawer is showing [#1788]
  • Fixed an issue on Android with the program that audio still play in the background when the screen is on [#1785]
  • Fixed an issue where the paused audio is automatically played when game switch from background to foreground [#145]
  • Fixed an issue when changing Spine/DragonBones material on native platforms, position go wrong [#148]
  • Fixed an issue on native platforms where opacity of Spine/DragonBones incorrect at first frame [#148]
  • Fixed an issue where cc.sys.languageCode can’t get full language area code on Android [#1784]

Web

  • Improve support for IE11 [#5033]
  • Fixed an issue where clicking the EditBox clear button which comes with Edge browser does not trigger the input event [#5088]
  • Fixed an issue where EditBox’s text size failed to scale with Node during the input process [#5088]
  • Fixed an issue where audio can’t play on Edge and Baidu browsers [#4910]
  • Fixed a problem where audio might not play on desktop Chrome and Safari [#4991]
  • Fixed an issue where desktop UC browser play WebAudio reports errors [#5048]

Mini Game

  • Fixed the problem that atlas does not support rotation on Open Domain of Mini Game platforms [#4325]

Downloads:

v2.1.3-alpha.3(Windows | Mac


Cocos Creator does not support downgrades, so please be sure to back up your project before using the beta!

Note: If you have a custom engine, please revert to the editor built-in engine, otherwise the new version editor will not be available if the version does not match.

Please reply here for all the questions related to the beta. Do not post separately. This post is for feedback only, please do not reply to irrelevant content.

Posts: 2

Participants: 1

Read full topic

Ability to turn off WebGL in v 2.1.2

$
0
0

@buggy_glitch wrote:

Hey Guys,
As the title says ,how do I deactivate/turn off WebGL in the current latest version of cocos creator(v 2.1.2).

Reason: I am still getting WebGL not supported on device error.

Please help.

Posts: 1

Participants: 1

Read full topic

Viewing all 17057 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>